Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**************PLEASE EXAMINE MY ANSWER AND RESPOND TO IT!!!!!!!!!!!!!!!!!!!!!!!!

ID: 3710437 • Letter: #

Question

**************PLEASE EXAMINE MY ANSWER AND RESPOND TO IT!!!!!!!!!!!!!!!!!!!!!!!! DO NOT JUST POST A GENERAL SOLUTION AS I NEED SPECIFIC HELP ON SPECIFIC PARTS OF THE PROBLEM, NOT JUST A GENERIC ANSWER.**********************

Ð Write a C program that will display text on any terminal. The program should first prompt the user for the name of the device ?le for the terminal on which to display output, as well as the output to display. It should then perform the necessary I/O operations. This process should repeat until the user decides to exit the program.

FEEDBACK: The only part I cannot get to work is writing and reading to the file. Please help me with this section of my code.

MY ANSWER:

#include int main) FILE *fpt; char c[30]; char words; char text[30]: while(1) printf("Enter the terminal to display in (Q to quit): "); scanf("%s" if(c[0] 'Q') return 0; printf("Enter the text to display:"); scanf("%s", &words;); if(c[9] '0') == fpt fopen( "c","w"); fprintf(fpt, "%s", &words;); fclose(fpt); fpt = fopen ( "c","r"); fscanf(fpt,"%s", text); printf("%s ", text); fclose(fpt); else if(c[9] |-'0') printf("Unable to open %s for writing", &words;);

Explanation / Answer

Lets discuss the issues and thier solutions

Declare string as
char words[100];
scanf("%s", words);
Remove the if condition first , Control is NOT going inside if block
if(c[9]='0' ) ==> REMOVE THIS LINE FIRST


1) Declare the file name as "input.txt" instaed of single character "c"
=> fpt = fopen("input.txt", "w");

2)fprintf(fpt, "%s", words);