#include<sstream>
#include<time.h>
#include<iostream>
#include<cstdlib>
#include<fstream>
using namespace std;
const int MAX_FILE = 10000;
int main()
{
unsigned int sum = 0;
for (int n = 0; n < MAX_FILE; ++n)
{
stringstream s;
int value = 0;
float totaltime=0.0;
clock_t start, end;
s << n << ".txt";
//cout << s.str() << endl;
start = time(NULL);
ifstream in(s.str().c_str());
if (!in)
{
// Cannot open file
}
else
{
while (!in.eof())
{
in >> value;
//cout << value;
sum += value;
}
}
in.close();
}
ofstream out("output.txt");
out.close();
end=clock();
cout << "sum=" << sum << endl;
totaltime = (float)(end - start);
cout << "花費時間=" <<totaltime<< endl;
system("pause");
return 0;
}
但
error C2065: 'start' : 未宣告的識別項
error C2065: 'totaltime' : 未宣告的識別項
IntelliSense: 識別項 "totaltime" 未定義
原本讀寫檔所有都可正常執行
但計算執行時間加了clock_t宣告start,end和clock()之後就不能執行
真的很奇怪,根本沒什錯誤啊
我用vb 2013
我換dev也是一樣= =
請問各位高手這要怎麼處理?
作業都寫出來了,卻卡在這裡...
大家幫幫我
