#include<iostream>
#include<conio.h>
#include<fstream>
#include<string>
#include<string.h>
#include<vector>
using namespace std;
void main()
{
string read;
string name;
vector<string> myvec;
const char * word;
ifstream in;
in.open("w.txt");
ofstream out;
getline(in,read);
word = strtok(&read[0],",");
while(word != NULL)
{
name = word;
cout<<"Word: "<<word<<endl;
name = name + ".txt";
myvec.push_back(name);
out.open(name);
cout<<"Name: "<<name<<endl;
word = strtok(NULL,",");
out.close();
}
in.close();
system("pause");
}
내가 겪고있는 문제는 우분투 터미널에서 실행할 때 일반적으로 out.open()이 문자열을 가져 오지 않는다고 말하는 오류가 발생한다는 것입니다. 이름.C++에서 변수에 이름을 전달하여 파일을 여는 방법
파일에서 다른 파일을 작성해야합니다. 문제를 해결할 수있는 방법이 있습니까?
[우분투 상자에서 C++ 11 (또는 그 이상) 툴체인 사용] (http://en.cppreference.com/w/cpp/io/basic_ofstream/open) 또는'name.c_str)'보다는'name'을 사용하십시오. – WhozCraig
'out.open (name.c_str())'시도해 보셨습니까? –