What do the error codes / error values / statuses mean in C?

I know that:

  • Returning 0 means the program successfully executed.
  • Returning -1 means the program failed to execute properly.
  • You can return with your own exit code and make it mean whatever you want with e.g. exit(69)

I have searched on the internet and also found something around operating systems having their own error codes such as Linux having error codes from 0 to 255, and Windows (the operating system I am using) using error codes in the format 0xc0000000 (correct me if I’m wrong on any of this.)

However when I am using Code::Blocks IDE, I have two error codes/values, for example:

Process returned with status -1073740940 (0xC0000374)

I searched for 0xC0000374 and found that it meant heap corruption, so it was useful.

However searching for an almost random number of -1073740940 got me nowhere, so IN GENERAL what is this value? Why, when the program has to be terminated due to some error, does this value have to be so large and random?
Is it some variable inside the program that got corrupted due to some undefined behavior? Where did it come from?

Thanks in advance.

>Solution :

The two values you’re seeing in this case are identical.

The decimal value -1073740940, when represented as a 32-bit two’s complement value in hexadecimal is 0xC0000374. The value is just being displayed two different ways.

Leave a Reply