(c programming)
Given the function declaration and documentation below, write the function definition. Do not use the standard library function fgetc.
/// @brief Reads a character from specified file input stream. /// @param instream A FILE* variable for an input stream to read a character from. /// @return A character of type char from instream. /// @note This function assumes #include <stdio.h> and a working, valid FILE* variable to an input stream. char grabchar(FILE* instream);
#include <stdio.h>
char grabchar(FILE* instream);
int main()
{
FILE* instream = fopen("sample.txt", "r") ;
printf("%c",grabchar(instream));
return 0;
}
char grabchar(FILE* instream)
{
char ch;
fscanf(instream,"%c", &ch);
return ch;
}
Get Answers For Free
Most questions answered within 1 hours.