Skip to content

Instantly share code, notes, and snippets.

@caioluders
Created April 12, 2018 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caioluders/5ee3637ef7d14387e77b3d50e6e168ff to your computer and use it in GitHub Desktop.
Save caioluders/5ee3637ef7d14387e77b3d50e6e168ff to your computer and use it in GitHub Desktop.
int main(int argc, char *argv[]) {
int i;
char s[MAX_CMD_LINE], c;
memset(s, 0, MAX_CMD_LINE);
// Loop until Ctrl+C is pressed
for (i=0; ; i++) {
if ((c = getchar()) == EOF) // End Of File reached when reading from a pipe
break;
if (c == '\n') {
examine(s);
memset(s, 0, MAX_CMD_LINE);
i=-1;
putchar('\n');
}
s[i] = c;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment