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

Please insert a code that will write the 4 strings to a file instead of the scre

ID: 3846732 • Letter: P

Question

Please insert a code that will write the 4 strings to a file instead of the screen.

Editable Code:

____________________________________________________________________

#include

int main (void)

{

FILE *fp_out;

char *str1 = “Four score and seven years ago our”;

char *str2 = “fathers brought forth on this continent,“;

char *str3 = “a new nation, conceived in Liberty and dedicated“;

char *str4 = “to the proposition that all men are created equal.”;

fp_out = fopen("my_file", "w");

if( fp_out != NULL )

{

// Insert your code here to write the 4 strings above to the file my_file

fclose(fp_out);

}

else printf("I couldn't open the file "my_file". ");

return 0;

}

_____________________________________________________________________

Thanks in advanced!

#include

Explanation / Answer


#include <stdio.h>
int main (void)
{
FILE *fp_out;
char *str1 = “Four score and seven years ago our”;
char *str2 = “fathers brought forth on this continent,“;
char *str3 = “a new nation, conceived in Liberty and dedicated“;
char *str4 = “to the proposition that all men are created equal.”;
fp_out = fopen("D:Tempoutfile.txt", "w");
if( fp_out != NULL )
{
fputs(fp_out, *str1);
fputs(fp_out, *str2);
fputs(fp_out, *str3);
fputs(fp_out, *str4);
fclose(fp_out);
  
}
else printf("I couldn't open the file "my_file". ");
return 0;
}