Reputation: 829
I still very new to c++ so I probably did something weird. I'm writing a program that prints xmas trees to the screen. I've been able to do just using a string now I want to store parts of it in a variable and call each part as i need it. I keep on getting a c2679 error and a c4129 warning.
Okay now my questions:
Do I have to worry about the warnings since they do not need to be escaped?
How do I fix the c2679 error?
#include <iostream><string>
using namespace std;
int main()
{
cout << "This is tree number "<< 1 <<endl;
cout << "\t\t\t\t *\n\t\t\t\t ***\n\t\t\t\t *****\n\t\t\t\t\*******\n\t\t\t\t ***\n\t\t\t\t ***\n";
string aa,a,b,c,d;
aa = "This is tree # ";
a = "\t\t\t\t *";
b = "\n\t\t\t\t ***";
c = "\n\t\t\t\t *****";
d = "\n\t\t\t\t\*******";
cout << aa;
system("Pause");
return 0;
}
Upvotes: 0
Views: 68
Reputation: 14049
Don't have a \
before the *
.
Remove the \
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "This is tree number "<< 1 <<endl;
cout << "\t\t\t\t *\n\t\t\t\t ***\n\t\t\t\t *****\n\t\t\t\t*******\n\t\t\t\t ***\n\t\t\t\t ***\n";
string aa,a,b,c,d;
aa = "This is tree # ";
a = "\t\t\t\t *";
b = "\n\t\t\t\t ***";
c = "\n\t\t\t\t *****";
d = "\n\t\t\t\t*******";
cout << aa;
system("Pause");
return 0;
}
\
denotes the start of an escape sequence. The characters you have after a \
are t
, n
, \
etc.
http://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences
Also change
#include <iostream><string>
to
#include <iostream>
#include <string>
Upvotes: 1