+ 1
can you help me ?i want to replace line10 to 20 of the test file to test 2 file but i can`t do with fgets(st, 20, fin2)
#include<iostream> #include<fstream> #include<string.h> #include <stdio.h> using namespace std; int main() { ifstream fin; ifstream fin2; ofstream fout; string st; string solve[30]; int i; fin.open("test.txt"); if(!fin) cout<<"connot open1\n"; for(i=0 ; i<10 ; i++) { fin>>st; solve[i]==st; fout<<solve[i]; } fin2.open("test2.txt"); if(!fin) cout<<"connot open2\n"; int j; i=10; while(!fin2.eof()) { fin>>st; cout<<"string ["<<i<<"]---> "; fgets(st, 20, fin2); j = i; i++; } fin2.close(); fin.close(); fout.close(); return 0; }
1 Antwort
0
You should not mix C file operation with C++ file operation. Those are two different stuffs.