I need to keep prompting the user until they give me 1 argument. I have a while(1) loop with a break statement inside but it exits early when it is run with 2 arguments. How do I continue prompting instead of exiting? I want to do something like this:
bool flag = true;
while(flag)
{
// ..code
flag = false;
}
but that does not work in C. This is what I have so far.
int main(int argc, char* argv[])
{
while(1)
{
if(argc == 2)
{
reverse(argv[1]);
printf("Reversed string: %s\n", argv[1]);
}
else
{
printf("Error, wrong number of arguments. Please provide only one argument");
}
break;
}
return 0;
}
I tried deleting the break statement and got an infinite loop, as expected, but no "pause" of execution for the input argument.