I'm suppose to execute the program in cmd prompt like this:

fifo.exe data.txt

However, I cannpt even get the program name which is fifo.exe.
I found out that argc (parameter of main) does not even go to 1.
It shows -1 instead.
Why is this so?
Anyone can help me?!?!

I actually created a class right above the main program.
Below is how i type the main:
int main (int argc, char *argv[])

#include <stdio.h>

int main(int argc, char *argv[])
{
   int i;
   printf("argc = %d\n", argc);
   for (i = 0; i < argc; ++i)
   {
	  printf("argv[%d] = \"%s\"\n", i, argv[i]);
   }
   return 0;
}

/* my output
C:\Test>testpp.exe data.txt
argc = 2
argv[0] = "C:\Test\testpp.exe"
argv[1] = "data.txt"
*/
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.