首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

关于文本的有关问题,不知道是程序有有关问题还是方法不对

2012-03-02 
关于文本的问题,不知道是程序有问题还是方法不对?我的程序是保存在E盘中,并且在E盘中建了两个文本a.txt和b

关于文本的问题,不知道是程序有问题还是方法不对?
我的程序是保存在E盘中,并且在E盘中建了两个   文本a.txt和b.txt,a.txt   中输入一些字母;
在提示下输入E:\a.txt和E:\b.txt
能编成功但是在输入后却显示应运程序错误,引用某处的内存,什么不能为 "written "
#include   <stdio.h>
#include   <stdlib.h>
#include   <ctype.h>
int   main   (void)
{
    char*file1;
    char*file2;
    char   ch;
    FILE*in,*out;
    fprintf(stdout, "please   enter   one   files:\n ");
    fscanf(stdin, "%s ",file1);
    fprintf(stdout, "please   enter   one   files:\n ");
    fscanf(stdin, "%s ",file2);
    if((in=fopen(file1, "r "))==NULL)
            {
    fprintf(stderr, "cant   open   file   %s\n ",file1);
            exit(1);
    }
    if((out=fopen(file2, "w "))==NULL)
            {
    fprintf(stderr, "cant   open   file   %s\n ",file2);
            exit(2);
            }
    while((ch=getc(in))!=EOF)
                {
ch=toupper(ch);
putc(ch,out);
          }
  fclose(in);
  fclose(out);
    return   0;
    }


[解决办法]
检查一下有没file1对应的文件

热点排行