bashコマンドの出力を文字列のベクトルに1行ずつ読み取る必要があります。このコードをifstreamで試しましたが、エラーが発生します。ifstreamの代わりにそれらを解析するために何を使用する必要がありますか?
using namespace std;
int main()
{
vector<string> text_file;
string cmd = "ls";
FILE* stream=popen(cmd.c_str(), "r");
ifstream ifs( stream );
string temp;
while(getline(ifs, temp))
text_file.push_back(temp);
for (int i=0; i<text_file.size(); i++)
cout<<text_file[i]<<endl;
}