The function getc () in C
The function int getc (FILE * stream) in C Library standard takes the next character (an unsigned char) from the given Stream and increases the position indicator for that Stream.
The function int getc (FILE * stream) in C Library standard takes the next character (an unsigned char) from the given Stream and increases the position indicator for that Stream.
Declare getc () function in C
Below is the declaration for the getc () function in C:
int getc ( FILE * stream )
Parameters
stream - This is the pointer to a FILE object that identifies the Stream on which the operation is performed.
Returns the value
This function returns the character read as an unsigned char that is cast to an int or EOF or an error.
For example
The following program C illustrates the usage of the getc () function in C:
#include int main () { char c ; printf ( "Nhap ky tu: " ); c = getc ( stdin ); printf ( "Hien thi ky tu vua nhap: " ); putc ( c , stdout ); return ( 0 ); }
Compiling and running the above C program will result:
According to Tutorialspoint
Previous lesson: Function fputs () in C
Next lesson: getchar () function in C
You've just finished reading the article "The function getc () in C" edited by the TipsMake team. You can save the-function-getc-in-c.pdf to your computer here to read later or print it out. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.