Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <process.h>
  4.  
  5.  
  6. using namespace std;
  7. int main(int argc, char *argv[]) {
  8.  
  9. cout << "argc = " << argc << endl;
  10. for (int i = 0; i < argc; i++) {
  11. cout << "Argument: " << i << " = " << argv[i] << endl;
  12. }
  13.  
  14. if (argc != 2) {
  15. cout << "Error" << endl;
  16. exit(-1);
  17. }
  18. char ch;
  19. ifstream infile;
  20. infile.open(argv[1]);
  21. if (!infile) {
  22. cout << "errrrror: cant open a file" << argv[1];
  23. exit(-1);
  24. }
  25. while (infile) {
  26. infile.get(ch);
  27. cout << ch;
  28. }
  29. cout << endl;
  30.  
  31. system("pause");
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement