Is a = getchar开发者_如何学JAVA() equivalent to scanf(\"%c\",&a);? Is putchar(a) equivalent to printf(\"%c\",a); where a is a char variable?Generally speaking yes they are the same.
#include <stdio.h> int main() { char read = \' \'; while ((read = getchar()) != \'\\n\') { putchar(read);
in the example: #include <stdio.h> main() { long nc; nc = 0; while (getchar() != EOF) ++nc; printf(\"%ld\\n\", nc);
I\'m creating a program which follows certain rules to result in a count of the words, syllables, and sentences in a given text file.
How I can use getchar() in a loop? Now I have... for (p=0; p<n_players; p++) { ... fflush(stdin); getchar();
I\'m writing a program which is supposed to read two strings that can contain line breaks and various other characters. Therefore, I\'m using EOF (Ctrl-Z or Ctrl-D) to end the string.