ch21_1.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //**********************
- //** ch21_1.cpp **
- //**********************
- #include <fstream.h>
- #include <iostream.h>
- #include <stdlib.h>
- void main(int argc, char ** argv)
- {
- ifstream source(argv[1]); //打开文件
- char line[128];
- try{
- if(source.fail())
- throw argv[1];
- }
- catch(char* s)
- {
- cout <<"error opening the file "<<s <<endl; exit(1);
- }
- while(!source.eof()){
- source.getline(line, sizeof(line));
- cout <<line <<endl;
- }
- source.close();
- }