0

In the next code:

#include <stdio.h>

int main(void) {   
  int c;   
  while ((c=getchar())!= EOF)      
    putchar(c); 
  return 0;
}

I have to press Enter to print all the letters I entered with getchar, but I don't want to do this, what I want to do is to press the letter and immediately see the the letter I introduced repeated without pressing Enter. For example, if I press the letter 'a' I want to see an other 'a' next to it, and so on:

aabbccddeeff.....

But when I press 'a' nothing happens, I can write other letters and the copy appears only when I press Enter:

abcdef 
abcdef

How can I do ? in my windows 11 GNU Compiler

abcdef 
abcdef

  • 1
    https://stackoverflow.com/questions/421860/capture-characters-from-standard-input-without-waiting-for-enter-to-be-pressed/ – Hans Passant Mar 11 '23 at 10:46

0 Answers0