不会的~你可以试一下~最好判断一下文件是否成功打开~cout<<"please input the filename:";cin>>filename;file.open(filename.c_str());if(!file){ cerr<<"file open fail"< exit(-1);}