CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Nov 2010
    Posts
    94

    Question C++ version of sscanf, sprintf, etc?

    Are there C++ equivalents of sscanf and sprintf functions that takes a pointer to the C++ string class as the argument?

    Also what's the C++ equivalent of printf to do formatted output? Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,031

    Re: C++ version of sscanf, sprintf, etc?

    Quote Originally Posted by acppdummy
    Are there C++ equivalents of sscanf (...) functions that takes a pointer to the C++ string class as the argument?
    Not that I know of, so you might either use a stringstream, or create a std::string s with the desired size and then pass &s[0] as an argument to sscanf (but then be warned about the danger of buffer overflow, plus you need to account for the null terminator).

    Quote Originally Posted by acppdummy
    what's the C++ equivalent of printf to do formatted output?
    You can use Boost.Format for something similiar.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

+ Reply to Thread

Bookmarks

Posting Permissions

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



HTML5 Development Center

Click Here to Expand Forum to Full Width