Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <iostream>
  6. #include <fstream>
  7. #define MAX 256
  8. using namespace std;
  9.  
  10. int main(int argc, char** argv)
  11. {
  12. FILE *fp;
  13. char buf;
  14. int max, min, n=0;
  15. char ch;
  16. if(argc<3)
  17. { cout << "Wrong arguments" << endl; exit (-1);}
  18. sscanf(argv[2], "%d%*c%d;", &min, &max);
  19. if (( max < min) || (min<0) || (max>255)) { cout << "error range"<< endl; exit(-1); }
  20. ifstream in (argv[1]);
  21. if(!in)
  22. { fprintf(stderr, "Cannot open file\n"); return 0; }
  23. while (in){
  24. in.getline(ch);
  25. if(in) { buf = ch; n++; cout << (int)buf << " " << (int)ch <<endl;
  26. }}
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement