Header file:
stdio.h
Synopsis:
int putchar(int c);
Description:
It is equivalent to putc(c, stdout).
putchar function C example:
#include<stdio.h>
int main() {
char ch;
FILE *fp;
fp = fopen("input.txt", "r");
while ((ch = fgetc(fp)) != EOF)
putchar(ch);
return 0;
}
int main() {
char ch;
FILE *fp;
fp = fopen("input.txt", "r");
while ((ch = fgetc(fp)) != EOF)
putchar(ch);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/exp$ ls
a.out input.txt
jp@jp-VirtualBox:~/cpgms/exp$ cat input.txt
Hello world
This is putchar example program in C
Thanks for visiting our blog
jp@jp-VirtualBox:~/cpgms/exp$ ./a.out
Hello world
This is putchar example program in C
Thanks for visiting our blog
a.out input.txt
jp@jp-VirtualBox:~/cpgms/exp$ cat input.txt
Hello world
This is putchar example program in C
Thanks for visiting our blog
jp@jp-VirtualBox:~/cpgms/exp$ ./a.out
Hello world
This is putchar example program in C
Thanks for visiting our blog
No comments:
Post a Comment