#include <iostream>
#include <fstream>
using namespace std;
#include <stdlib.h>//system() exit()
#define MAX_LINE_LENGTH 100
int main(int argc,char *argv[])
{
if(argc!=2)
{
cout<<"用法:ShowFile文本文件名"<<endl;
system("PAUSE");
exit(1);
}
ifstream inFile(argv[1]);
if(inFile.fail())
{
cout<<"打开文件"<<argv[1]<<"失败!"<<endl;
system("PAUSE");
exit(2);
}
char str[MAX_LINE_LENGTH];
inFile>>str;
while(!inFile.eof())
{
cout<<str<<endl;
inFile>>str;
}
inFile.close();
system("PAUSE");
return 0;
}
c++文件
最新推荐文章于 2023-04-06 23:43:56 发布