#include typedef struct { void * next; char ch; int g, b; } Fmt; void format( Fmt * f ) { if ( __builtin_expect(f->next != 0, 1) ) goto *f->next; f->next = &&s1; 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 = { NULL }; format( &fmt ); // prime for ( ;; ) { scanf( "%c", &fmt.ch ); // direct read into communication variable if ( feof( stdin ) ) break; format( &fmt ); } fmt.ch = '\0'; format( &fmt ); } // Local Variables: // // tab-width: 4 // // compile-command: "gcc-8 Format1.c" // // End: //