You are welcome!!!
Greetings to Indonesia!![]()
This is a discussion on If Else Statement Goes Error!!! within the C Programming forums, part of the General Programming Boards category; You are welcome!!! Greetings to Indonesia!...
You are welcome!!!
Greetings to Indonesia!![]()
Code - functions and small libraries I use
__________________________________________________ __________________________________________________ ______________
It’s 2013 and I still use printf() for debugging.
Yes. The comma operator does not change return semantics. What will happen instead is that the left expression will be evaluated followed by the right.
As in this program. As the author may have intended to return both the new value of x and 0, it doesn't really work, and in any case, the main() function was not prepared to receive 2 things. Instead, the new value of x is a side effect of invoking foobar(). Which is bad because you want functions to have clear expectations of input and output.Code:#include <stdio.h> int x = 1; int foobar(void) { int y = 0; return x *= 4, y; } int main(void) { int rv; printf("x before foobar() = %d\n", x); rv = foobar(); printf("foobar() returned = %d\n", rv); printf("x after foobar() = %d\n", x); return 0; }
If you pack variables into a structure, you can return as many values as you want, but you are still returning a single object.
Some logical errors, like this one, cannot be stopped by the compiler as well.hmmm, i already change that and compile again
still had errors
Originally Posted by phantomotap