I've used getchar and putchar to succeessfully print my entered char to the screen before, however I've changed the code slightly and now it prints my entered char twice in a row. Code:
#include <stdio.h>
int main()
{
int charInput;
printf("Enter a char >> ");
charInput = getchar();
printf("%c", putchar(charInput));
return 0;
}
I know I could just use putchar without the printf but I wanted to experiment with them. The output I get is:
Enter a char >> a
aa
2 chars are printed to the screen?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…