VC ++。net中执行文件读取代码时出错

时间:2013-12-13 17:17:39

标签: c++ .net visual-c++ compiler-errors

我正在尝试阅读包含近60000字的文本文件。 这是我为它编写的代码..编译器显示以下错误消息: FileReading.exe中0x77cee3be处的未处理异常:0xC0000005:此行的访问冲突读取位置0x02affa79。 cout<<“阅读词......< 但是当我在调试模式下运行此代码时..编译器没有显示任何错误。一切都很好..请帮帮我... 我正在为控制台应用编写此代码。

int Per=25;
int inter=14527;
if(ifile)
{
    while(!ifile.eof())
    {
        ifile>>input;
                   /* doing some work here

                  */

        noOfWord++;

                 //i want to show this info to user..  Total percentage of words
                   read from file  ...like "Reading Words ... 25%"

        //if(noOfWord==inter)
        //{
        //  //Sleep(1000);
        //  cout<<"Reading Words..."<<Per<<"%";
        //  inter*=2;
        //  Per+=Per;
        //}
    }
}
else
{
    cout<<"File Not Open";
    exit(0);
}

1 个答案:

答案 0 :(得分:0)

cout<<"Reading Words...<<Per<<"%";不好 - 你忘了终止引用。

您想要cout<<"Reading Words..."<<Per<<"%";