Write a Character: putc () and fputc () The putc functions write a character to the file stream specified which can be a user-defined stream, stdout, or stderr. The functionality of putc/ fputc same. For the function takes two arguments. The first parameter is the character to be written and the second parameter is the file, The second parameter is the file pointer declared as FILE. If the character is successfully written, the function returns it. If any occurs, it returns EOF. Syntax, putc (char, *fp); fputc (char, *fp); Example, char ch; ch = getc (stdin); /* input from keyboard */ putc (ch, stdout); /* output to the screen */ putc (ch, outfileptr); /*output to a file */ 6.6 LINE I/O FUNCTIONS Reading Strings: gets () and fgets () The gets and fgets function take a line (terminated by a new line) from the input stream and make a null-terminated string out of it. These are sometimes called line-to-string input function. gets ()
Write a Character: putc () and fputc () The putc functions write a character to the file stream specified which can be a user-defined stream, stdout, or stderr. The functionality of putc/ fputc same. For the function takes two arguments. The first parameter is the character to be written and the second parameter is the file, The second parameter is the file pointer declared as FILE. If the character is successfully written, the function returns it. If any occurs, it returns EOF. Syntax, putc (char, *fp); fputc (char, *fp); Example, char ch; ch = getc (stdin); /* input from keyboard */ putc (ch, stdout); /* output to the screen */ putc (ch, outfileptr); /*output to a file */ 6.6 LINE I/O FUNCTIONS Reading Strings: gets () and fgets () The gets and fgets function take a line (terminated by a new line) from the input stream and make a null-terminated string out of it. These are sometimes called line-to-string input function. gets ()
Character-IO-Functions.docx