CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    92

    the difference between <cstring> <sstream> <string>

    the difference between <cstring> <sstream> <string>
    can somebody help me to explain this , and give some example
    Last edited by walkinginwater; December 6th, 2004 at 05:43 AM. Reason: there is a mistake in my post

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: the difference between <cstring> <sstring> <string>

    Quote Originally Posted by walkinginwater
    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
    Code:
    #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;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured