Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Can anybody explain me below statement ?
Forum Updated to NodeBB v4.3 + New Features

Can anybody explain me below statement ?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
3 Posts 2 Posters 499 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    I want to understand the below statement in terms of programming can any body help me ?
    no need to extract a std::string from a std::stringstream when its only use is to get its content via c_str()

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      Something like this:
      std::stringstream ss("this is a string\n");
      const std::string& tmp = ss.str();
      const char* cstr = tmp.c_str();
      std::cout << " ====== " << cstr << std::endl;
      It may mean that you do not need a copy of the string when you need only c_str().

      Q 1 Reply Last reply
      1
      • JoeCFDJ JoeCFD

        Something like this:
        std::stringstream ss("this is a string\n");
        const std::string& tmp = ss.str();
        const char* cstr = tmp.c_str();
        std::cout << " ====== " << cstr << std::endl;
        It may mean that you do not need a copy of the string when you need only c_str().

        Q Offline
        Q Offline
        Qt embedded developer
        wrote on last edited by
        #3

        @JoeCFD so what exactly i need to write instead of it. can you give example.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved