Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <sstream>
  5. #include <vector>
  6. using namespace std;
  7.  
  8. int main(int argc, char* argv[])
  9. {
  10. if (argc!=3)
  11. {
  12. cerr<<"Error, need 2 arg"<<endl;
  13. return(-1);
  14. }
  15. int startInd, endInd;
  16. char semicolon;
  17. ifstream input(argv[1]);
  18. vector<char> buf;
  19. string strVector;
  20. stringstream str;
  21. if (input==0)
  22. {
  23. cerr<<argv[1]<<"Can't open to read"<<endl;
  24. return(-2);
  25. }
  26. str<<argv[2];
  27. if (!(str>>startInd>>semicolon>>endInd))
  28. {
  29. cerr<<"err"<<endl;
  30. return(-3);
  31. }
  32. if ((semicolon!='-') || (startInd>endInd) || (startInd<0) && (endInd<0))
  33. {
  34. cerr<<"err"<<endl;
  35. return(-4);
  36. }
  37. char c;
  38. while(input.get(c))
  39. {
  40. buf.push_back(c);
  41.  
  42.  
  43. /*if (buf.size()<endtInd)
  44. continue;
  45. for (int i=0; i<buf.size(); i++)
  46. {
  47. if ((i>=startInd) && (i<=endInd))
  48. {
  49. if ((int)buf[i]<32)
  50. {
  51. cout<<buf[i];
  52. }
  53. }
  54. else
  55. cout<<buf[i];
  56. }*/
  57. if(c=='/n'){
  58. cout<<"efe";
  59. for(int i=startInd;i<endInd;i++){
  60. if((int)buf[i]>32){
  61. buf.erase(buf.begin()+i);}
  62. }
  63. for(int i=0;i<buf.size();i++)
  64. cout<<buf[i];
  65. cout<<endl;
  66. buf.clear();
  67. }}
  68.  
  69.  
  70. input.close();
  71. return(0);
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement