How do I empty a string to obtain an empty line whe I "cout" it?
How do I empty a string to obtain an empty line whe I "cout" it?
Do you mean you want to write a blank line to the screen? Try:
cout <<endl;
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
hehe - sorry, but that's not the problem.
The string is returned by a function an only in certain cases it must be empty...
so I need to return an EMPTY string:needs to give me the spare line.Code:cout << string << endl;
Well if it's a std::string, I suppose:
std::string * s = new string(" ");
For a char array, do:
strcpy(s, " ");
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
You can use
in case where an empty std::string is to be returned.return "";
@ Sebastiani: that's it - thank you
Functions clear() and erase() in the string class as well as over assignment operators do not assume that you want to clear everything from a string when you use one of the functions or the operator. From an STL string class perspective, a string object can hold more than just characters.
One solution is to set the string object array to NULL and then call clear().
KuphrynCode:string sText; // Get a line of data from cin buffer. // getline() terminates on ENTER key. std::getline(cin, sText); // Clear the entire object. sText[sText.size()] = NULL; sText.clear();