Click to See Complete Forum and Search --> : the difference between <cstring> <sstring> <string>


walkinginwater
December 6th, 2004, 04:17 AM
the difference between <cstring> <sstream> <string>
can somebody help me to explain this , and give some example

Andreas Masur
December 6th, 2004, 04:28 AM
the difference between <cstring> <sstring> <string>
can somebody help me to explain this , and give some example

'<cstring>' is provided only for backward compatibility with ANSI C and provides the global string functions such as 'strcpy', 'strcat', 'memcpy' etc.
'<sstring>' is not a header I know....I assume you rather mean '<sstream>' which provides the stream classes for strings.
'<string>' is the header file for the STL 'string' class...

A sample would be

#include <iostream>
#include <sstream>
#include <string>

int main()
{
std::ostringstream oss;
oss << 10;
std::string str = oss.str();
std::cout << str << std::endl;
return 0;
}