Use the std::getline()
from <string>
.
istream & getline(istream & is,std::string& str)
So, for your case it would be:
std::getline(read,x);
More Related Contents:
- Using getline() in C++
- What am I not understanding about getline+strings?
- cin.getline() is skipping an input in C++ [duplicate]
- Getline keeps on getting newline character. How can I avoid this?
- What is the difference between palindrome permutation and permutation? [closed]
- How to convert an instance of std::string to lower case
- Convert string to variable name or variable type
- Getting std :: ifstream to handle LF, CR, and CRLF?
- How do I convert a double into a string in C++?
- Fastest way to get IPv4 address from string
- How do I check if a C++ string is an int?
- How I can print the wchar_t values to console?
- How can I get double quotes into a string literal?
- Find out if string ends with another string in C++
- C++ string to enum
- Split a string using C++11
- Case insensitive std::string.find()
- Convert String containing several numbers into integers
- How to read cin with whitespace up until a newline character?
- How to use string.substr() function?
- how to pre-allocate memory for a std::string object?
- Assign a nullptr to a std::string is safe?
- Comparing strings lexicographically
- Copy a streambuf’s contents to a string
- c++ sizeof( string )
- Why can’t the switch statement be applied to strings?
- ifstream not reading EOF character
- How can a char pointer be initialized with a string (Array of characters) but an int pointer not with an array of integer? [duplicate]
- Forcing String to int Function to Consume Entire String
- How to get file extension from string in C++