简体   繁体   中英

Can't getline() from istringstream (C++)

I have a previously declared char c[64]; and I'm trying to look at the first word of the output of a pipe:

read(pipe_replacement_to_main[READ_END], c, BUF_SIZE);
istringstream response_stream(string(c));
string response_string;
getline(response_stream, response_string, ' ');

And gcc gives me the following at that fourth line:

error: no matching function for call to ‘getline(std::istringstream (&)(std::string), std::string&, char)’

I can't even figure out how it's trying to call the function. Did I declare the istringstream wrong?

最烦恼的解析 ,在response_stream的构造函数中添加一对括号。

istringstream response_stream((string(c)));

A nice demonstration of the true "power" of C++.

The way you declared the response_stream variable, it is actually a function rather than type istringstream .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM