[問題] fin 未宣告的識別項
我執行了下列程式
#include <iostream>
#include <dirent.h>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
DIR *D;
struct dirent *Dirpath
ifstream fin;
cout<<"please input the file path \n" ;
cout<<"path:" ;
string filepath;
getline(cin,filepath);
D = opendir(filepath.c_str());
while (Dirpath = readdir(D))
{
if( strcmp(Dirpath->d_name, ".") != 0 && strcmp(Dirpath->d_name, "..")!= 0 )
{
string file_in=filepath+Dirp->d_name;
fin.open(file_in.c_str(),ios::in|ios::binary);
if (fin.is_open())
{
while(!fin.eof())
{ }
}
else
{cout<<"file open error\n";}
fin.close();
}
}
system("PAUSE");
return 0;
}
然而卻出現 error C2065: 'fin' : 未宣告的識別項
1>c:\vc_test\vc_test\vc_test.cpp(150) : error C2228: '.open' 的左邊必須有類別/結構/等位
1> 型別為 ''unknown-type''
1>c:\vc_test\vc_test\vc_test.cpp(151) : error C2065: 'fin' : 未宣告的識別項
1>c:\vc_test\vc_test\vc_test.cpp(151) : error C2228: '.is_open' 的左邊必須有類別/結構/等位
1> 型別為 ''unknown-type''
1>c:\vc_test\vc_test\vc_test.cpp(153) : error C2065: 'fin' : 未宣告的識別項
1>c:\vc_test\vc_test\vc_test.cpp(153) : error C2228: '.eof' 的左邊必須有類別/結構/等位
1> 型別為 ''unknown-type''
請問我是哪裡沒宣告到??? 謝謝!!! 使用VC++ 2008
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.124.182.35
→
09/25 16:32, , 1F
09/25 16:32, 1F
→
09/25 16:32, , 2F
09/25 16:32, 2F
→
09/25 17:23, , 3F
09/25 17:23, 3F
→
09/25 17:41, , 4F
09/25 17:41, 4F
推
09/25 17:45, , 5F
09/25 17:45, 5F
推
09/25 17:47, , 6F
09/25 17:47, 6F
→
09/25 19:20, , 7F
09/25 19:20, 7F
→
09/25 19:22, , 8F
09/25 19:22, 8F
→
09/25 19:23, , 9F
09/25 19:23, 9F
→
09/25 19:26, , 10F
09/25 19:26, 10F
→
09/25 19:28, , 11F
09/25 19:28, 11F
→
09/25 19:30, , 12F
09/25 19:30, 12F
→
09/25 19:35, , 13F
09/25 19:35, 13F
推
09/25 19:39, , 14F
09/25 19:39, 14F
→
09/26 15:47, , 15F
09/26 15:47, 15F
→
09/26 15:48, , 16F
09/26 15:48, 16F
→
09/26 15:54, , 17F
09/26 15:54, 17F
→
09/26 15:55, , 18F
09/26 15:55, 18F
推
09/26 16:11, , 19F
09/26 16:11, 19F
推
09/26 16:13, , 20F
09/26 16:13, 20F
→
09/26 16:14, , 21F
09/26 16:14, 21F
→
09/26 16:23, , 22F
09/26 16:23, 22F
推
09/26 16:25, , 23F
09/26 16:25, 23F
→
09/26 16:25, , 24F
09/26 16:25, 24F
→
09/26 16:25, , 25F
09/26 16:25, 25F
→
09/26 17:01, , 26F
09/26 17:01, 26F
→
09/26 17:01, , 27F
09/26 17:01, 27F
→
09/26 17:03, , 28F
09/26 17:03, 28F
→
09/26 17:03, , 29F
09/26 17:03, 29F
→
09/27 12:46, , 30F
09/27 12:46, 30F
→
09/27 12:47, , 31F
09/27 12:47, 31F
推
09/28 13:14, , 32F
09/28 13:14, 32F