stupid question.. what's "return 0"?

Started by
30 comments, last by Inmate2993 18 years, 6 months ago
If a function returns a struct then (at least in gcc) if the struct is larger than 8 bytes (I think that's it on x86) a pointer is passed by the calling function and the result is written out to that address.
Advertisement
Actually, quite a lot of functions in the standard C library don't return error codes through the return, they assign the error code to errno.

When it comes to a return type, its best to stick to how the function will be called. "Procedures" to borrow a term from Pascal, don't have return types. In C, C++, and Java, the void keyword is used for this purpose.

Exceptions also make a great way to pass errors.
william bubel

This topic is closed to new replies.

Advertisement