English 中文(简体)
我开始记录我档案的细节以来发生了什么?
原标题:What happened since I started logging details about my file?

我在窗口7上用C:B书写了一个方案,我对此有问题。 这里是我用来核对档案中线数的代码。 第一部分是宣布行距功能,随后是法典的一部分,其中我计算档案中的线数。 在我开始增加伐木过程之前,所有物品都做了罚款。 Maybe 我的伐木信息是错误的,或在单一职能范围内开立和关闭太多的档案? 如果能帮助查明我的错误,我将非常感激。 我很乐意就我的问题提出更详细的或澄清。 我仍在学习C++,因此,我感到非常困惑的是,为什么我的方案停止计算线。

std::ifstream& GotoLine(std::ifstream& file, unsigned int num)
{
file.seekg(std::ios::beg);
for(int i=0; i < num - 1; ++i)
{
    file.ignore(std::numeric_limits<std::streamsize>::max(), 
 );
}
return file;
}


ifstream productguide;

   productguide.open ("MasterProductGuide.csv");

   if (productguide.good())
   {

        c = productguide.get();
        if (c== 
 )x++;

        ofstream log;
        log.open ("log.txt", ofstream::app);

        if (log.good())
        {
            time_t rawtime;
            struct tm * timeinfo;
            time ( &rawtime );
            timeinfo = localtime ( &rawtime );
            string loginfo;
            loginfo = asctime (timeinfo);
            log << "MarketManager Detected " << x << " # of lines in the Master Product Guide - " + loginfo;
        }
        else
        {
            cout << "There was an error creating the log file" << endl;
            cout << "The Program will now terminate" << endl;
            system("PAUSE");
            return 0;
        }
        log.close();

   }
   else
   {
        ofstream log;
        log.open ("log.txt", ofstream::app);

        if (log.good())
        {
            time_t rawtime;
            struct tm * timeinfo;
            time ( &rawtime );
            timeinfo = localtime ( &rawtime );
            string loginfo;
            loginfo = asctime (timeinfo);
            log << "MarketManager Failed to oped the Master Product Guide - " + loginfo;
        }
        else
        {
            cout << "There was an error creating the log file" << endl;
            cout << "The Program will now terminate" << endl;
            system("PAUSE");
            return 0;
        }
        log.close();

        cout << "The Program will now terminate" << endl;
        system("PAUSE");
        return 0;
   }

   productguide.close();
问题回答

看看这部法典,我看看你的记录只是随附而打开。 因此,它最终会大得多。

我可以说,这部法典不会失败的另一个原因,但一个超过2gb的档案肯定会达到could。 我不记得,如果快乐模式存在问题,但内部可能使用。 寻求无疑会产生大量档案的问题。 您将使用<代码>fseek64。 职能家庭。 视窗有自己的版本,为不兼容起见,带有强调力。

当你与溪流合作时,你也应检查其错误旗帜,当事情发生错误时,它实际上赢得了 throw。 你在公开后检查,但其他行动也可能失败。

更具体地说,<代码>呼吁:istream:ignore。 页: 1 eof. 从设计角度看,我非常怀疑这一点。 它可能发挥作用,但肯定会通过法律审查。

As a nitpick, errors should be printed to std::cerr and return 1. :)





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签