argc and argv in Visual C++

  • Thread starter Thread starter GerryWolff
  • Start date Start date
G

GerryWolff

Guest
With the following test program, the value of argc is always 1, even though the command arguments are Hello World. What am I doing wrong?

Test program:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char *out_filename;
FILE *output_file;
errno_t err;

int main(int argc, char* argv[])
{
out_filename = *++argv; // Name of file containing element
// syntax and descriptions.
if ((err = fopen_s(&output_file, "out_filename", "w")) != 0) return 0;
fprintf(output_file, "Hello World\n\n");
fprintf(output_file, "Program name: %s \n", argv[0]);
return 1;
if (strcmp("Hello", argv[1]) == 0) return 0;
fprintf(output_file, "%s", argv[1]) ;
fprintf(output_file, "%s", argv[2]) ;
fclose(output_file);
return 1;
}

Continue reading...
 
Back
Top