+ 1
What is the difference between return 0; return 1; return -1; in C programming Language ?
2 Réponses
+ 4
0 means program worked succesful
1 means general error
-1 means 255 beacuse main cannot return negative exit status
+ 2
Assuming these are exit codes, it's kindof up to you what they mean (it's why documentation is nice), but lots of programs use these numeric codes for interprocess communication / logging:
Microsoft:
https://docs.microsoft.com/en-us/windows/desktop/debug/system-error-codes
Linuxes (just an example; there are other lists):
https://github.com/torvalds/linux/blob/master/tools/arch/parisc/include/uapi/asm/errno.h
[meta, for readers]
Note that negative return codes will wrap around as Olek Szczepura indicates; Microsoft errors like (-2147217865 ) are often more easily found converted to hexadecimal: 0x80040e37