Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Revprint
//gcc 4.9. //Revprint Copyright(C) 2016 Henry Kroll III www.thenerdshow.com #include <stdio.h> #include <stdlib.h> #include <string.h> #define strlen(s) ( (s==NULL) ? 0 : strlen(s) ) #define SPLIT(S, TOK, res) for (res=strtok(S,TOK); res; res=strtok(NULL," ")) #define DUP(t, s) char t[strlen(s) + 1]; strcpy(t, s); #define MDUP(fn, s) strcpy(fn(strlen(s) + 1), s) #define ALT(fn, s) s = MDUP(fn, s) #define ForEach(s, t) void *t; for (int _id=0;(t = s[_id]);_id++) 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 -----------------------", NULL }; void revprint (char *p, int max_tokens) { char *result, *result_array[max_tokens]; DUP(s, p); /* tokenize */ int results = 0; SPLIT(s, " ", result) { result_array[results++] = result; if (results >= max_tokens) break; } /* reverse */ while (results--) { printf ("%s ", result_array[results]); } puts (""); } int main (void) { ForEach(s, line) { revprint (line, 15); } return 0; }
run
|
edit
|
history
|
help
0
ptr_tp_ptr
c union bytes affected
709 lab 3.1
150116_OrdenMatriz
PART 2
02468
guia 4 terminada
gets.c
Exercicio de C - Vetor Multidimensional
test