0
int main(void) {
    char type;
    while(scanf("%c", &type)) {
        printf("%c\n", type);
    }
}

I would like to get one character and do something in while loop. Unfortunetly when I type for example yyy while loop iterate 3 times. How can I flush or cut string for only one char?

This solution is still not working

int main(void) {
  int type;
  while((type = getchar()) != '\n' && type != EOF) {
    printf("%c\n", type);
  }
}
Mati
  • 753
  • 4
  • 20

0 Answers0