Home > Net >  How to resolve Exception Error in C Builder
How to resolve Exception Error in C Builder

Time:08-01

I am in the process of converting an older DOS based 16-bit application into a current Windows console app. Each time I run the application in debug mode I receive the following error:

Project xxxx.exe raised exception class $C0000005 with message 'access violation at 0x004151f9: read of address 0x00000000'.

The following is the code line that blows up:

if ((argc < 1) || (strcmp(argv[1],"/?")) == 0) prg_syntax();

The code evaluates and should run the function to display the programs syntax but doesn't and instead throws the error.

I am using C Builder version (11.1.5).

Any help of where or how to overcome I would greatly appreciate.

Thanks, Kent

CodePudding user response:

The argc cannot be lower than 1, because it will have at least the name / symbolic link to the execution (binary) file. In the case of no arguments passed to the program it will try to deference NULL pointer (the last element of argv[]).

  if ((1 < 1) || (strcmp(NULL,"/?")) == 0) prg_syntax();

I believe you've wanted to do something like this:

  if ((argc < 2) || (strcmp(argv[1],"/?")) == 0) prg_syntax();
  • Related