我在窗口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();