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

C Programming. I was given this code to input into Windows Visual Studio. The ou

ID: 3717482 • Letter: C

Question

C Programming.
I was given this code to input into Windows Visual Studio.
The output has to be the dupfile shown.
I need someone to help me modify it to properly compile. it says I need to use fopen_s and when I change it then it says "too few arguments for call". also it tells me to use fscanf_s. nothing seems to work. please help.

This program makes a duplicate copy of a file. ( reads input from a file and write output to another file ) #include 2 int main) 4 FILE infile; FILEoutfile; 6 int age; char name[20] infile fopen("a:myfile.txt","r"); outfile fopen("a:dupfile.dat", "w"): 10 if (infile NULL) printf"File does not exist.in"); 12 13 else printf("Program execution successful.'n"); 14 while (fscanf(infile, "%s%d", name, &age;) !-EOF) 15 16 17 18 fprintf(outfile, "%s %don", name, age); fclose(infile); 19 fclosefoutile) 19 20 return (0); 21 /l create text file: Start-Programs- Accessories - NotesPad

Explanation / Answer

c code:

#include "stdafx.h"

#include <stdio.h>

#include <stdlib.h>

#include <conio.h>

int main()

{

FILE *inFile, *outfile;

errno_t err;

int age;

char name[20];

fopen_s(&outfile, "dupfile.txt", "w")

if ((err=fopen_s(&infile, "myfile.txt", "r"))==0)

{

// file exists: don't read a char before the loop or

// it will be lost

while (fscanf_s(inFile, %s%d, &name,&age) != EOF)

{

fprintf(outfile, "%s %d ", name,age);

}

fclose(inFile);

fclose(outfile);

}

else

{

fprintf(stderr,"Cannot open file, error %d ",err);

}

//it will copy and write on dupfile..

for any clarification, do comments..