티스토리 뷰

string이 들어있는 파일을 읽어서 한 줄씩 vector에 넣는 코드

#include <bits/stdc++.h>

using namespace std;


vector<string> ReadLine(string s) {

vector<string> r;

string line("");

ifstream in(s.c_str());

if (in.is_open())

{

while (!in.eof())

{

getline(in, line);

r.push_back(line);

}

in.close();

}

return r;

}


int main() {

string filename;

cin >> filename;


vector<string> v;

v = ReadLine(filename);


  string Output = "aaa"

ofstream ofs;

ofs.open(Output);


ofs << 1 ;

ofs.close();


return 0;

}


작성자 : 히더

'공부 > SW' 카테고리의 다른 글

오버헤드 (Overhead)  (0) 2018.10.09
[Kotlin] Kotlin과 Java  (0) 2018.09.28
[C++] int를 string으로, string을 int로  (0) 2018.08.31
[C++] string 헤더 함수 정리  (0) 2018.08.30
[Android] 구글 Firebase  (0) 2018.08.24
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함