访问冲突
#include <stdio.h>#include <stdlib.h>
#include <ctype.h>
#define SIZE 30
int main(void)
{
char source;
char target;
char ch;
FILE *fp;
FILE *fa;
printf("Enter the source file:\n");
gets(source);
if ((fp = fopen(source, "r")) == NULL)
{
printf("Can't open the %s file.\n", source);
exit(EXIT_FAILURE);
}
printf("Enter the target file.\n");
gets(target);
if ((fa = fopen(target, "w")) == NULL)
{
printf("Can't open the %s file.\n", target);
exit(EXIT_FAILURE);
}
while ((ch = getc(source)) != EOF)
{
ch = toupper(ch);
putc(ch, target);
}
if (fclose(source) == NULL)
printf("Can't close %s file.\n", source);
if (fclose(target) == NULL)
printf("Can't close %s file.\n", target);
getchar();
return 0;
}
为什么在while循环哪里会发生访问冲突?
参数不对,一个char,一个int,不匹配 楼主,问题解决了,请结帖!
页:
[1]