게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
c++ 이개 왜 다 끝난다음에 에러가 뜨죠?
게시물ID : programmer_20190짧은주소 복사하기
작성자 : 한시운
추천 : 0
조회수 : 394회
댓글수 : 1개
등록시간 : 2017/04/04 14:41:45
#pragma hdrstop
#pragma argsused
#include <algorithm>
#include <tchar.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main() {
string copy;
string copy1;
cout << "택스트을 copytest_1.txt으로부터 copytest_2.txt로 복사합니다.\n";
ifstream in("copytest_1.txt");

if (in.is_open()) {
// 위치 지정자를 파일 끝으로 옮긴다.
in.seekg(0, ios::end);

// 그리고 그 위치를 읽는다. (파일의 크기)
int size = in.tellg();

// 그 크기의 문자열을 할당한다.
copy.resize(size);

// 위치 지정자를 다시 파일 맨 앞으로 옮긴다.
in.seekg(0, ios::beg);

// 파일 전체 내용을 읽어서 문자열에 저장한다.
in.read(&copy[0], size);

for (; ;) {
if (copy[copy.find('\n')] == ' ') {
break;
}
else {
copy[copy.find('\n')] = ' ';
}
}

cout << copy << endl;
}

in >> copy;
ofstream fout("copytest_2.txt");
fout << copy;
return 0;
}
//택스트 copytest_1.txt와 copytest_2.txt는 따로 만드셔야 됩니다.
//copy.find가 원인인것 같긴한대....
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호