I’m reading input to a char array of size 5,
stringstream ss;
char a[5];
if (!ss.read(a, 5))
{
// throw exception
}
if (!ss.get(a, 5))
{
// throw exception
}
Both of these functions seem to work, is there any difference?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ss.readwill read 5 bytes from the stream, unless it hits the end of the stream.ss.getwill read 4 bytes, unless it hits the delimiter (‘\n’) or end of the stream. It will also null-terminate the string.