"Unget string" function
void ungets(char* str, FILE* stream) { if (!str || !file) return -1; size_t len = strlen(str); for (int i=len-1; i>=0; i--) if (ungetc(str[i], stream) == EOF) return -1; return len; }
DZone Snippets > Minimiscience > writing
12388 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
void ungets(char* str, FILE* stream) { if (!str || !file) return -1; size_t len = strlen(str); for (int i=len-1; i>=0; i--) if (ungetc(str[i], stream) == EOF) return -1; return len; }