Hi -
Here's an example that might help:
1. Here's the program:
Code:
#include <stdio.h>
int
main (int argc, char *argv[])
{
printf ("argc= %d...\n", argc);
for (int i=0; i < argc; i++)
{
printf ("argv[%d]= %s...\n", i, argv[i]);
}
return 0;
}
2. Here's the build (sorry: my linux dev box isn't handy at the moment ;-):
Quote:
C:\temp>vcvars32
C:\temp>cl hello.cpp
|
3. And finally, here's a sample run (with corresponding sample output):
Quote:
C:\temp>hello a b c
argc= 4...
argv[0]= hello...
argv[1]= a...
argv[2]= b...
argv[3]= c...
|
4. Here's another example:
Quote:
C:\temp>hello major kong
argc= 3...
argv[0]= hello...
argv[1]= major...
argv[2]= kong...
|
5. And yet another example:
Quote:
C:\temp>cd \
C:\>c:\temp\hello dr. strangelove or how i learned to stop worrying and love the bomb
argc= 14...
argv[0]= c:\temp\hello...
argv[1]= dr....
argv[2]= strangelove...
argv[3]= or...
<< snipped >>
argv[12]= the...
argv[13]= bomb...
|
I hope that helps .. PSM