It's UWAweek 47

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying selected article
Showing 1 of 828 articles.
Currently 126 other people reading this forum.


 UWA week 32 (2nd semester, week 3) ↓
SVG not supported

Login to reply

👍?
helpful
6:35am Tue 6th Aug, Christopher M.

ANONYMOUS wrote:
> I was just wondering if there was a difference between declaring main as an int function and returning 0 on success, and declaring main as a void function and returning EXIT_SUCCESS.
Firstly, since the C99 standard (and hence in C11), main() must be a function returning an int, so you'll typically see: int main(void) or int main(int arc, char *argv[]); Within main() you can either return an integer value, or call the exit() function with an integer parameter. Of course the exit() function doesn't return, so you should only use it when you want the whole program to terminate at that point, and it shouldn't be used if main() should return to another function in the same program (rare). We should use EXIT_SUCCESS or EXIT_FAILURE in preference to 0 and 1 (so we don't have to remember what 0 means), but not all programs terminate with just a 0 or 1 exit status - see man zip, for example, which describes 19 different exit statues. More reading: [stackoverflow]

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy