Answered step by step
Verified Expert Solution
Question
1 Approved Answer
HELP WITH THESE TWO FUNCTIONS PLEASE. Write a function that defines a structure, initializes it, writes it to a file called struct.out, closes the file,
HELP WITH THESE TWO FUNCTIONS PLEASE.
Write a function that defines a structure, initializes it, writes it to a file called "struct.out", closes the file, re-opens the file for read-only access, reads a single structure into a new struct variable and then closes the file. Print the structure contents to the screen. On any error, return -1. 0therwise return . Write a function called read_and_print) that will do the following: Open a text file called "hello.txt" for read-only access. Read a word that is terminated by a newline from the file into the character array called "my_string". . Read an integer terminated by a newline into the int variable called "my_int" Print the string and the integer value. . Return the my_int value. If the file cannot be opened for reading, return1 If an error occurs while reading from the file, return -1 Write a function that defines a structure, initializes it, writes it to a file called "struct.out", closes the file, re-opens the file for read-only access, reads a single structure into a new struct variable and then closes the file. Print the structure contents to the screen. On any error, return -1. 0therwise return . Write a function called read_and_print) that will do the following: Open a text file called "hello.txt" for read-only access. Read a word that is terminated by a newline from the file into the character array called "my_string". . Read an integer terminated by a newline into the int variable called "my_int" Print the string and the integer value. . Return the my_int value. If the file cannot be opened for reading, return1 If an error occurs while reading from the file, return -1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started