Skip to content

Instantly share code, notes, and snippets.

@jautero
Created August 8, 2014 23:33
Show Gist options
  • Save jautero/8907c4aa9afcf46447bf to your computer and use it in GitHub Desktop.
Save jautero/8907c4aa9afcf46447bf to your computer and use it in GitHub Desktop.
I am Groot.
#include <stdio.h>
#include <stdio.h>
char *groot="I am Groot. ";
void grootstream(FILE *stream)
{
int count=0;
int len=strlen(groot);
int input;
while ((input=fgetc(stream))!=EOF) {
if (input >= ' ') {
putchar(groot[count++]);
if (count==len) {
count=0;
}
} else {
putchar(input);
}
}
}
int main(int argc, char **argv)
{
FILE *file;
int fcount;
if (argc<2) {
grootstream(stdin);
} else {
for (fcount=1;fcount<argc;fcount++) {
file=fopen(argv[fcount],"r");
if (file) {
grootstream(file);
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment