#include
using namespace std;
int main() {
ifstream infile;
string filepath;
cout << "file path: " << endl;
cin >> filepath;
infile.open(filepath.c_str());
if (infile.fail()) {
// error...
}
...
infile.close();
}
大概就是这个流程吧,如果我没理解错你的意思.
#include
using namespace std;
void main()
{
FILE *fp;
char Fs[256];
char ff[256];
cin>>Fs;
if ( NULL == ( fp = fopen( Fs, "ab+" ) ) )
{
system("pause");
exit(1);
}
while ( fgets( ff, 100, fp ) )
{
cout<
cout<<"\n";
system("pause");
fclose( fp );
}
回答者:匿名 5-21 11:44
正解。
回答者:匿名 5-21 11:44
高人!
说清楚啊,是用C++打开文件?