fork download
  1. #include<iostream>
  2. #include<fstream>
  3. #include<string>
  4. #include<string.h>
  5. #include<sstream>
  6.  
  7. using namespace std;
  8.  
  9. string int2str(int &);
  10.  
  11. int main(void)
  12. {
  13. char* ptrInName = NULL;
  14. ptrInName = new char[500];
  15. char* ptrOutName = NULL;
  16. ptrOutName = new char[500];
  17.  
  18. int x = 0;
  19.  
  20. cout << "Input:" << endl;
  21. cin >> ptrInName ;
  22.  
  23. cout << "\n" << "每幾列取一列:" << endl;
  24. cin >> x;
  25.  
  26. string y;
  27. y = int2str(x);
  28.  
  29. strcpy(ptrOutName, ptrInName);
  30.  
  31. char strtoChar[2];
  32. strcpy(strtoChar, y.c_str());
  33. strcat(strtoChar, ".xyz");
  34. char total[] = "-";
  35. strcat(total, strtoChar);
  36.  
  37.  
  38. char *pch = NULL;
  39. pch = strstr(ptrOutName,".xyz");
  40.  
  41. int num = strlen(total);
  42.  
  43. strncpy (pch,total,num);
  44.  
  45. cout << "\n" << "Ouput:" << "\n" << ptrOutName << endl; //
  46.  
  47. char* file1 = ptrInName;
  48. char* file2 = ptrOutName;
  49. ifstream inFile1( file1 );
  50. ofstream outFile( file2 );
  51.  
  52. string ptrInNametoString;
  53. ptrInNametoString.assign(ptrInName);
  54.  
  55. ifstream ipfile;
  56. char text;
  57.  
  58. ipfile.open(ptrInName);
  59. int aa = 0;
  60. while (ipfile.get(text))
  61. {
  62. if (text=='\n')
  63. {
  64. aa++;
  65. if ( (aa%x) == 0)
  66. {
  67. outFile << "1\n";
  68. }
  69. }
  70.  
  71. }
  72.  
  73. inFile1.close();
  74. outFile.close();
  75.  
  76. system("pause");
  77. return 0;
  78. }
  79.  
  80. string int2str(int &i)
  81. {
  82. string s;
  83. stringstream ss(s);
  84. ss << i;
  85.  
  86. return ss.str();
  87. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:76:19: error: 'system' was not declared in this scope
     system("pause");
                   ^
stdout
Standard output is empty