#include typedef struct { int restart, g, b; char ch; } Fmt; void format( Fmt * f ) { static void * states[] = {&&s0, &&s1}; goto *states[f->restart]; s0: f->restart = 1; for ( ;; ) { for ( f->g = 0; f->g < 5; f->g += 1 ) { // groups for ( f->b = 0; f->b < 4; f->b += 1 ) { // blocks return; s1: if ( f->ch == '\0' ) goto fini; // EOF ? while ( f->ch == '\n' ) return; // ignore // printf( "%c", f->ch ); // print character } // printf( " " ); // block separator } // printf( "\n" ); // group separator } fini:; // if ( f->g != 0 || f->b != 0 ) printf( "\n" ); } int main() { Fmt fmt = { 0 }; format( &fmt ); // prime fmt.ch = 'a'; for ( long int i = 0; i < 1000000000; i += 1 ) { // scanf( "%c", &fmt.ch ); // direct read into communication variable // if ( feof( stdin ) ) break; format( &fmt ); } fmt.ch = '\0'; // sentential (EOF) format( &fmt ); } // Local Variables: // // tab-width: 4 // // compile-command: "gcc-8 Format1.c" // // End: //