   [C++] stringstream
  I'm trying to use stringstream, but it always gives me an error, and I don't know why.. I included iostream, string and sstream just to be sure it's not the problem..#include <iostream>#include <string>#include <sstream>...stringstream stm("String");...What am I doing wrong?Thanks for any helpers,Portishead.   
  std::stringstream , unless you put the lineusing namespace std;   ;  Some more source code, and perhaps what error you are seeing would certainly help. As godsenddeath said, you are likely not dealing with the std namespace correctly.   ;  Didn't know it was in std namespace..Now I'm trying to do this, but it still gives an error:std::stringstream stm;//Also tried this:std::stringstream stm("string");Btw, I'm in a windows application, and these are the headers I include:iostream,window,commctrl.   ;  Try using std::ostringstream (for when you want to write to the string) or std::istringstream (for when you want to read from it) instead. And you will need to include sstream.   ;Quote:Original post by PortisheadNow I'm trying to do this, but it still gives an error:*** Source Snippet Removed ***You do realize there are thousands if not millions of errors one can get from faulty code?  We're not psychic; we need the actual error.   ;  This is the error:error C2079: 'name_stm' uses undefined class 'std::basic_stringstream<_Elem,_Traits,_Alloc>'And this is what I'm trying to do:I have a counter (int), and a string(char*, not std::string), and I'm trying to add the counter to the string each time I call the function(Name1, Name2...).   ;  I would recommend using std::string and boost::lexical_cast.  char* is error prone and doesn't have the convenient functionality of std::string.  To quote Zahlman - "As a general rule, if you post in For Beginners and your code contains the word 'char', you have a bug. std::string roxors teh big one one one one."Anyway, having the actual error helps, but it's kind of ambiguous as to exactly what is wrong.  Can you post the code?[Edited by - MikeTacular on April 29, 2009 1:05:28 PM];Quote:Btw, I'm in a windows application, and these are the headers I include:iostream,window,commctrl.Your earlier code showed you including something else (like <sstream>). Don't post fragments that are meaningless on their own. Post a real thing like:#include <iostream>#include <string>using namespace std;int main(){    stringstream ss("hello world"); //doesn't compile};  this compiles#include <sstream>#include <string>#include <iostream>int main(){std::stringstream ss("str");return 0;}*EDIT i should mention that i only threw <string> and <iostream> in because you had it, you don't have to include those headers to use stringstream