I'm almost sure to be right about the following:
If you've got two variables,
x and
argc, (used for command-line input) and you want to make a loop where
x will constantly be raised by one, started with value 1, until the value of
argc is reached.
To me, the most neat approach to do that is by using
for:
Code:
for ( x = 1 ; x == argc ; x++ )
{
( ... )
}
Now I just can't believe my eyes, because on my box, this
does not work. All code (the ( ... ) ) simply won't be executed. The only way to get this working, is the following:
Code:
int main(int argc, char **argv)
{
int x;
if (argc == 1)
PrintUsage ();
else
for ( x = 1 ; ; x++ )
{
if (x == argc)
break;
printf ("%i %s\n", x, argv[x]);
}
Head ();
Body ();
Tail ();
}
Have I overlooked something?The above example _does_ work, but the first should, too! Right?