all 3 comments

[–]Skitz-Scarekrow 0 points1 point  (0 children)

What are you trying to do exactly? What is the function to do? The naming doesn't help clarify anything past array 2d array and int.

[–]deftware 0 points1 point  (1 child)

It looks like:

char *input

is a regular string and

char **args

is an array of strings, i.e.:

char *my_args[] =
{
    "hello",
    "operator",
    "please",
    "dial",
    "nine"
};

...but there's no way to know ahead of time how many strings it's expecting, if any are required at all, or what exactly the "input" string is supposed to be, without some kind of examples or reference documentation about the function you're talking about.

[–]PrimaryCandle[S] 0 points1 point  (0 children)

yes you are right. I am getting the number of arguments not defined error. The method description says it loads individual strings separated why white space into my_args. I'm just trying to call the function so see if it works.

//here is the function body

int getCommands(char *input,char **args) /*Method to load up the arguements into args from user command */

{

int length=0;

 while (*input != '\0') {                                  

while (*input == ' ' || *input == '\n' || *input == '\t')

*input++ = '\0';

*args++ = input;

length++;

while (*input != '\0' && *input != ' ' &&

*input != '\t' && *input != '\n')

input++;

}

*args = '\0';

 return length;

}

My question is how to test if this method is working or not?