<span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 1</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> #</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">include</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> <</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">iostream</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 2</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> #</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">include</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> <fstream> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 3</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">using</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">namespace</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">std</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">; </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 4</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 5</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">int</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> main() </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 6</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> { </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 7</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> ifstream fin(</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: maroon">"test1.txt"</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">); </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 8</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> ofstream fout(</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: maroon">"test2.txt"</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">); </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 9</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 10</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">if</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">(fin==</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">NULL</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">) </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 11</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> { </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 12</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">cout</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"><<</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: maroon">"Error"</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"><<</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">endl</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">; </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 13</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 14</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">return</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: maroon">1</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">; </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 15</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> } </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 16</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 17</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">char</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> ch=fin.get(); </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 18</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 19</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">while</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">(ch!=</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: maroon">'\n'</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">) </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 20</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> { </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 21</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> fout.put(ch); </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 22</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> fin.get(ch); </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 23</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 24</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> } </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 25</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 26</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 27</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> fin.close(); </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 28</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> fout.close(); </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 29</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 30</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: blue">return</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> </span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: maroon">0</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal">; </span><br style="font-family: 'Courier New'; font-size: medium; line-height: normal" /><span style="font-family: 'Courier New'; font-size: medium; line-height: normal; color: teal"> 31</span><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"> } </span> <div><span style="font-family: 'Courier New'; font-size: medium; line-height: normal"><br /></span></div> <div><font face="Courier New" size="2"><span style="line-height: normal">test1에 있는 내용중 일단 한줄만 test2로 옮겼습니다.</span></font></div> <div><font face="Courier New" size="2"><span style="line-height: normal">근데 저는 옮기기 전에 string으로 내용을 옮기고 나서 모종의 작업을 거친후</span></font></div> <div><font face="Courier New" size="2"><span style="line-height: normal">test2로 옮기려고 하는데요</span></font></div> <div><font face="Courier New" size="2"><span style="line-height: normal"><br /></span></font></div> <div><font face="Courier New" size="2"><span style="line-height: normal">여기서 fout.put(ch)로 받은 ch를 하나의 string에 쭈욱 넣으려면 어떻게 해야하나요?</span></font></div> <div><font size="2">아니면 다른방식으로 test1에서 문자를 입력받아야 되는지 알려주시면 감사하겠습니다.</font></div>
대도서관 gta5 10,11화 완료, 2화 10분
http://tv304.com/board_orGS71
아프리카 해물파전
zen mate
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.