Re: std::stringstream with std::cout error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 3, 2017 at 3:07 PM, mahmood n via gcc-help
<gcc-help@xxxxxxxxxxx> wrote:
> ...
> Part of the code for that error is
>
> std::stringstream cmd;
> cmd << "a string”;
> int result = system(cmd.str().c_str());
> if(result){
>      std::cout << "Failed to execute: " << cmd << std::endl;
>      exit(1);
> }
>
> I changed that cout line to  cmd.str() and the error disappeared. However, I am not if I have to use cmd.str().c_str()?

You may want to change it to:

    std::cout << "Failed to execute: " << cmd.str() << std::endl;

It will print try to print embedded NULL's too in the case you have an
one in your command.

Jeff




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux