What is the purpose of getc() for?

Options
- read a character from any input stream
- read a character from a file
- both a and b above


CORRECT ANSWER : read a character from any input stream

Discussion Board
getc()-

-The correct answer is, both a and b above.
-getc() reads from any input stream i.e FILE stream or stdin.
-getchar() reads only from standard input stream i.e 'stdin'. As, you can use getc like getchar, using getc(stdin).
Syntax: int getc(FILE *stream);
e.g.
#include
int main()
{
printf("%c", getc(stdin));
return(0);
}

Sapna 02-15-2017 06:56 AM

read from stdin

correct answer is read character from stdin as user input first goes to stdin from there it will read

jb 07-15-2016 03:33 PM

getc() function.

Answer : read a character from file.

getc() returns a character from the specified FILE. The getc() function reads the next character (an unsigned char) from the specified stream and advances the position indicator for the stream.

Jayesh Sonar 02-24-2015 04:11 AM

correct answer

ans is read a character from STDIN.
STDIN is a file. a specified by OS. if you want to use other files, use fgetc() or change the file description of STDIN.
User input will be in STDIN file description.
Thus, the answer is STDIN

no 10-20-2014 06:22 AM

correct answer

ans is read a character from an input from user

naina 09-12-2014 07:25 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement