Tutorial by Examples

Jumping out of nested loops would usually require use of a boolean variable with a check for this variable in the loops. Supposing we are iterating over i and j, it could look like this size_t i,j; for (i = 0; i < myValue && !breakout_condition; ++i) { for (j = 0; j < mySecondVa...
Returning a value One commonly used case: returning from main() #include <stdlib.h> /* for EXIT_xxx macros */ int main(int argc, char ** argv) { if (2 < argc) { return EXIT_FAILURE; /* The code expects one argument: leave immediately skipping t...
Immediately continue reading on invalid input or break on user request or end-of-file: #include <stdlib.h> /* for EXIT_xxx macros */ #include <stdio.h> /* for printf() and getchar() */ #include <ctype.h> /* for isdigit() */ void flush_input_stream(FILE * fp); int main(v...

Page 1 of 1