Hi I am compilinig a C++ solution in VS2008.
ostringstream strout;
I am getting the compilation error "error C2065: 'ostringstream' : undeclared identifier".
I feel I have included all the necessary header files.
Can anyone kindly let me know how to fix this error (What all header files to include) ?
Also I am getting a strange error like "error C2146: syntax error : missing ';' before identifier 'strout'" at the same line.
Whereas I know that I havent missed ";" semi-colon @ the line whre the error is being thrown.
Thanks IN advance.
We can't tell you what's wrong with your code for sure, unless you show it to us.
But you can use the following and an example on how to do it:
#include <iostream>
#include <sstream>
int main() {
std::ostringstream oss;
oss << "Hello";
std::cout << oss.str() << '\n';
return 0;
}
The most likely cause is that you haven't actually included all the needed header files which is why it wouldn't recognise ostringstream
.
And it's that lack of recognition that's probably causing the missing semicolon error.
You need to
#include <sstream>
and qualify the name std::ostringstream
.