When i do this, the variable buf stays with the value "RETR ", it is like stringstream never existed.Code:/* string buf
stringstream ss;
int EmailBuf.ID;
*/
buf = "RETR ";
ss << EmailBuf.ID;
ss >> buf;
Printable View
When i do this, the variable buf stays with the value "RETR ", it is like stringstream never existed.Code:/* string buf
stringstream ss;
int EmailBuf.ID;
*/
buf = "RETR ";
ss << EmailBuf.ID;
ss >> buf;
Seams to be problem somethere elseCode:#include <iostream>
#include <string>
#include <sstream>
int main()
{
std::string buf("RETR ");
std::stringstream ss;
int ID = 6;
ss << ID;
ss >> buf;
std::cout << buf;
return 0;
}
/*
My output
6
*/
output should be RETR 6, but as i saw in your code it is ok, i will try some more in my program
No way. Maybe seeing a litlle bit more of the code...
Code:stringstream ss;
buf = sock->ReceiveLine();
if (buf[0] == '.')
break;
Email EmailBuf;
ss << buf[0];
ss >> EmailBuf.ID;
index = EmailBuf.ID;
index--;
buf = "RETR ";
ss << buf;
ss << EmailBuf.ID;
ss >> buf;
becasuse the strignstream contains spaces you cannot use >> to read from it the whole string ( >> stops on the first space)
Code:#include <iostream>
#include <string>
#include <sstream>
int main()
{
std::string buf("RETR ");
std::stringstream ss;
int ID = 6;
ss << buf << ID;
buf = ss.str();
std::cout << buf;
return 0;
}
/*
My output
RETP 6
*/