1 #include <iostream> 2 #include <fstream> 3 using namespace std; 4 5 int main() 6 { 7 ifstream fin("test1.txt"); 8 ofstream fout("test2.txt"); 9 10 if(fin==NULL) 11 { 12 cout<<"Error"<<endl; 13 14 return 1; 15 } 16 17 char ch=fin.get(); 18 19 while(ch!='\n') 20 { 21 fout.put(ch); 22 fin.get(ch); 23 24 } 25 26 27 fin.close(); 28 fout.close(); 29 30 return 0; 31 }
test1에 있는 내용중 일단 한줄만 test2로 옮겼습니다.
근데 저는 옮기기 전에 string으로 내용을 옮기고 나서 모종의 작업을 거친후
test2로 옮기려고 하는데요
여기서 fout.put(ch)로 받은 ch를 하나의 string에 쭈욱 넣으려면 어떻게 해야하나요?
아니면 다른방식으로 test1에서 문자를 입력받아야 되는지 알려주시면 감사하겠습니다.