I have a weird issue. Can some one help.
When I hardcode abc.bin to inputFileName - I can open the file in cpp. But when I pass the same using an optional argument, it fails. Note that in both cases, fprintf, prints the inputFileName as abc.bin properly.
I get can't open - no file or directory.
char * inputFileName;
char * optarg;
inputFileName = optarg; //doesn't work.
//inputFileName = "abc.bin"; //Works
fprintf(stderr, "inputFileName:%s \n",inputFileName);
if ( inFile != NULL )
inFile = fopen(inputFileName, "r+b");
if ( inFile == NULL )
"%s: can't open file %s: %s\n",
ProgName, inputFileName, strerror(errno));