void rev_print(char *s, int n) { for (; *s && isspace(*s); s++); if (*s) { char *e; for (e = s; *e && !isspace(*e); e++); rev_print(e, 0); printf("%.*s%s", (int)(e - s), s, " " + n); } if (n) putchar('\n'); }
int main(void) { char *s[] = { "---------- Ice and Fire ------------", " ", "fire, in end will world the say Some", "ice. in say Some ", "desire of tasted I've what From ", "fire. favor who those with hold I ", " ", "... elided paragraph last ... ", " ", "Frost Robert -----------------------", 0 }; int i; for (i = 0; s[i]; i++) rev_print(s[i], 1); return 0; }
int main() { struct node input; char entermore = '\0'; //getchar(); char delete_input = '\0'; while (entermore!='k') { printf ( "\n*******************************************************\n" ); printf ("i: Insert (Insert an element and keep the list ordered)\n"); printf ("d: Delete (Delete a node with the given value)\n"); printf ("p: Print (Print the content of the current list)\n"); printf ("q: Print Backward (Print the content of the current list - backwards)\n"); printf ("k: Quit (Quit the program)\n"); printf ( "*******************************************************"); printf ("\n Please enter your choice here:"); scanf( "%s", &entermore); getchar(); switch(entermore) { case 'i': printf( "Enter artist's name [100]: " ); input.artist = (char *) malloc(100); fgets(input.artist, 100, stdin); printf( "Enter album's name [50]: " ); input.album = (char *) malloc(100); fgets(input.album, 100, stdin); printf( "Enter song's name [200]: " ); input.song = (char *) malloc(200); fgets(input.song, 200, stdin); printf( "Enter date: " ); scanf( "%d", &input.date ); //get the first runtime printf( "Enter runtime: " ); scanf( "%d", &input.runtime ); insertItem(input); break; case 'd': printf( "Enter artist's name to delete: " ); fgets(&delete_input, 100, stdin); deleteItem(&delete_input); break; case 'p': print(); break; case 'q': rev_print(); break; case 'k': break; default: printf ("\n Invalid choice. Please try again.\n"); break; getchar(); } } return 0; }