主题:求助!
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define BUFSIZE 1024
int main(int argc,char *argv[])
{
int n;
char ch[BUFSIZE];
FILE *fp,*p;
if((fp = fopen(argv[1],"a+")) == NULL)
{
printf("Cant't open %s ",argv[1]);
exit(1);
}
p = fopen(argv[2],"w+");
if(setvbuf(fp,NULL,_IOFBF,BUFSIZE) != 0)
{
fputs("Can't append file to itself\n",stderr);
exit(1);
}
while(n = fread(ch,sizeof(char),1,fp) >0)
{
ch[BUFSIZE] = toupper(ch[BUFSIZE]);
fwrite(ch,sizeof(char),n,p);
}
fclose(fp);
fclose(p);
return 0;
}
[em58]怎么复制出来的文件不是大写的呀?!
#include <stdlib.h>
#include <ctype.h>
#define BUFSIZE 1024
int main(int argc,char *argv[])
{
int n;
char ch[BUFSIZE];
FILE *fp,*p;
if((fp = fopen(argv[1],"a+")) == NULL)
{
printf("Cant't open %s ",argv[1]);
exit(1);
}
p = fopen(argv[2],"w+");
if(setvbuf(fp,NULL,_IOFBF,BUFSIZE) != 0)
{
fputs("Can't append file to itself\n",stderr);
exit(1);
}
while(n = fread(ch,sizeof(char),1,fp) >0)
{
ch[BUFSIZE] = toupper(ch[BUFSIZE]);
fwrite(ch,sizeof(char),n,p);
}
fclose(fp);
fclose(p);
return 0;
}
[em58]怎么复制出来的文件不是大写的呀?!