Skip to content

Instantly share code, notes, and snippets.

@fxxkscript
Created March 22, 2014 04:07
Show Gist options
  • Select an option

  • Save fxxkscript/9700937 to your computer and use it in GitHub Desktop.

Select an option

Save fxxkscript/9700937 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define MAX_ARRAY 100
int main(int argc, char *argv[]) {
int i;
char s[MAX_ARRAY], c;
int lim = MAX_ARRAY;
setbuf(stdout, NULL);
setbuf(stdin, NULL);
// for (i = 0; i < lim - 1 && scanf("%c", &c) != '\n' && c != EOF; ++i) {
// s[i] = c;
// printf("%c", s[i]);
// }
// i = 0;
while (i < lim - 1) {
fprintf(stdout, "%c", c);
fflush(stdout);
scanf("%c", &c);
if (c == '\n') {
break;
} else if (c == EOF) {
break;
}
s[i] = c;
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment