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.

Code:
   main()
   {
   char * inputFileName;
   char * optarg;
   inputFileName = optarg;  //doesn't work.
   //inputFileName = "abc.bin"; //Works
    fprintf(stderr, "inputFileName:%s \n",inputFileName);
   }

Another function:
    FILE *inFile;
    if ( inFile != NULL )
    {
        inFile = fopen(inputFileName, "r+b");
        if ( inFile == NULL )
        {
            fprintf(stderr, 
                    "%s: can't open file %s: %s\n",
                    ProgName, inputFileName, strerror(errno));
            return NULL;
        }
    }
Thank you