Header file:
stdio.h
Synopsis:
int getchar(void);
Description:
Inputs a character. Returns integer value(ascii) of the character read.
getchar function C example:
#include<stdio.h>
int main() {
char ch;
FILE *fp;
fp = fopen("file.txt", "w");
while ((ch = getchar()) != EOF)
fputc(ch, fp);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/exp$ ./a.out
getchar example program in C
jp@jp-VirtualBox:~/cpgms/exp$ cat file.txt
getchar example program in C
getchar example program in C
jp@jp-VirtualBox:~/cpgms/exp$ cat file.txt
getchar example program in C
No comments:
Post a Comment