Home > Back-end >  The novice fread fwrite questions
The novice fread fwrite questions

Time:05-22

# include
# include
# include
Int main (int arg c, char * argv []) {
The FILE * fpin, * fpout;
Unsigned char buf [100].

Fout char fin [100], [100].
int n;
If (argcPrintf (" arg c=[% d] \ n ", arg c);
exit(0);
}
for (int i=0; iPrintf (" argv [I]=% s ", I, argv [I]);
}

Strcpy (fin, argv [1]);
Strcpy (fin, argv [2]);

Fpin=fopen (fin, "rb");
Fpout=fopen (fout, "wb");

N=fread (buf, sizeof (unsigned char), 100, fpin);
While (n==100) {
Fwrite (buf, seizeof (unsigned char), 100, fpout);
N=fread (buf, sezeof (unsigned char), 100, fpin);
}
return 0;
}


Line 26 fwrite (buf, seizeof (unsigned char), 100, fpout);
Such mistake could you tell me how to solve? [Error] expected primary - expression before 'unsigned,
And what I wrote the wrong place, can post don't know that for the first time

CodePudding user response:

The two sentence syntactically incorrect:
 fwrite (buf, sizeof (unsigned char), 100, fpout);//seizeof 
N=fread (buf, sizeof (unsigned char), 100, fpin);//sezeof

CodePudding user response:

 # include 
# include
# include

Int main (int arg c, char * argv [])
{
The FILE * fpin, * fpout;
Unsigned char buf [100].

Fout char fin [100], [100].
int n;
If (argc<3) {
Printf (" arg c=% d, what the arguments \ n ", arg c);
exit(0);
}
for (int i=0; i//printf (" argv [I]=% s ", I, argv [I]);
Printf (" argv [% d]=% s \ n ", I, argv [I]);
}

Strcpy (fin, argv [1]);
//strcpy (fin, argv [2]).
Strcpy (fout, argv [2]);

Fpin=fopen (fin, "rb");
if (! Fpin)
return -1;
Fpout=fopen (fout, "wb");
if (! Fpout)
return -1;

N=fread (buf, sizeof (unsigned char), 100, fpin);
While (n==100) {
//fwrite (buf, seizeof (unsigned char), 100, fpout);
//n=fread (buf, sezeof (unsigned char), 100, fpin);
Fwrite (buf, sizeof (unsigned char), 100, fpout);
N=fread (buf, sizeof (unsigned char), 100, fpin);
}
return 0;
}

For your reference ~

  • Related