stupid question.. what's "return 0"?
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement