Write a function named “hasHelpOption”that accepts argc and argv (same data typesof command line arguments), it will return true if it has the argument of “/help”or “/?”or “—help”and false otherwise.Please show how this function is being used and tested. C++ requires use pointer

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section: Chapter Questions
Problem 2PP
icon
Related questions
Question

Write a function named “hasHelpOption”that accepts argc and argv (same data typesof command line arguments), it will return true if it has the argument of “/help”or “/?”or “—help”and false otherwise.Please show how this function is being used and tested.

C++ requires

use pointer

Expert Solution
Step 1: algorithm

bool hasHelpOption(int argc,char **argv)
{
for(int i=0;i<argc;++i)
{
//any one of argv argument is one of the wanted then return true
//else return false
if(strcmp(argv[i],"/help")==0||strcmp(argv[i],"/?")==0||strcmp(argv[i],"--help")==0)
return true;
}
return false;
}
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr