(c programming)
Given the function declaration and documentation below, write the function definition. Do not use the the standard library function fputc.
/// @brief Writes a character to a specified file output stream. /// @param outstream A FILE* variable for an output stream to write a character to. /// @param outchar The character to be written to an output stream. /// @return On success, returns the written character. /// @note This function assumes #include <stdio.h> and a working, valid FILE* variable to an output stream. char placechar(FILE* outstream, char outchar);
char placechar(File* outstream, char outchar);
its function definition is below:
char placechar(FILE* outstream, char outchar){
//writing data of specified format to file
//fprintf will return the no. of characters
// written to file on success
int res = fprintf(outstream, "%c",outchar);
//if character has been written to file
if(res == 1)
return outchar;
//closing file
fclose(outstream);
return '\0';
}
Output:
if it helps you, do upvote as it motivates us a lot!
Get Answers For Free
Most questions answered within 1 hours.