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.
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..
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.