+ 2
What is wrong with this, it's driving me crazy... Any help would be appreciated. Please.
#include <iostream> using namespace std; int main() { string smiley = " @@@@ @@@@\n @@@@@@ @@@@@@\n @@@@@@ @@@@@@\n @@@@ @@@@\n\n\n\n@ @\n @@ @@\n @@@ @@@\n @@@@@ @@@@@\n @@@@@@@@@@@@@\n"; cout << smiley; } I've copied the solution exactly.. I don't understand what i'm doing wrong. Thanks in advance.
5 Answers
+ 3
Andrew
I don't know where you copied it from, but it is "invisibly" word wrapped.
In other words, the string need to be seen by the compiler as a single line. However this code breaks the string into multiple lines.
Try this - open a standard text editor. Turn the "word wrap" option off. The entire string should be on only one line, however you'll see that's not the case.
Another clear indication of this - when opened in the SoloLearn editor/compiler, everything in the string between the quotation marks should be green (at least it is for me; but should be some colour other than white). But in this case the @ characters are white - that's a giveaway that there are line breaks in the string (seperate lines, not one continuous line or string).
This can happen if you cut and paste from Internet sites etc.
FWIW fixed, normally I don't give solutions, just tips and hints (better to encourage self learning), but since this isn't really programming related...
https://code.sololearn.com/czqTHsBC3MRr/?ref=app
+ 2
What problem you are facing with the code?
+ 2
Jayakrishnađźđł
If you notice my comment it's because there are line breaks in the string which are not visible when only looking at the text. Try copying the poster's code into a compiler and you will see that the string is not actually a string, it's broken up by carriage returns (which are not visible in text).
This can happen when copying code from web pages and other sources, I know because I've experienced this many times first hand.
Here is what it looks like if the line breaks are not removed. Try compiling it, you will see the errors. And note that the string characters between quotation marks are not coloured, they are white, indicating it is not a working string.
https://code.sololearn.com/cNDF1BM7bm9G/?ref=app
+ 2
Scott D
Actually, the task of the course , gives you the working string for smiley, just like it is in your code. There is no need to change anything. Task is to output smiley just. May be, OP changed code..
Andrew , try reset code. Just add output statement. Don't change string value. It should work then.
+ 2
Jayakrishnađźđł
Ok, thanks, had no idea this was part of a course. I don't recall seeing it in the C++ course.