Feb 2, 2012 at 3:15am UTC
#include <iostream>
using namespace std;
int main()
{
const string LETTER_D =
"*******\n* *\n* *\n* *\n* *\n*******\n";
const string LETTER_A =
" * \n * *\n * *\n*********\n* *\n* *\n";
const string LETTER_N =
"* *\n* * *\n* * *\n* * *\n* * *\n* *\n";
const string LETTER_I =
"********\n * \n * \n * \n * \n********\n";
const string LETTER_E =
"********\n* \n***** \n***** \n* \n********\n";
const string LETTER_L =
"* \n* \n* \n* \n* \n********\n";
cout << LETTER_D;
cout << LETTER_A;
cout << LETTER_N;
cout << LETTER_I;
cout << LETTER_E;
cout << LETTER_L;
return 0;
}
This is the code however when i run this shows up:
cint -E -E U:\cs150home-S12\week01\HW03.cpp
Error: Assignment to LETTER_D type incompatible U:\cs150home-S12\week01\HW03.cpp(16)
!!! return from main() function
>Exit code: 0
does anyone know how to fix this? thank you
Feb 2, 2012 at 3:23am UTC
@daniel2012
Have you tried adding #include <string>;
I did, and everything printed, though every letter ran into the next. Try adding an extra newline \n
onto the end of const string. It'll look nicer.
Feb 2, 2012 at 3:26am UTC
Protip: You can define strings on multiple lines like this:
1 2 3 4 5 6
string s =
"ABCDEF"
"GHIJKL\n"
"MNOPQR"
"STUVWX\n"
"Y" "Z" ;
s contains:
ABCDEFGHIJKL
MNOPQRSTUVWX
YZ
Last edited on Feb 2, 2012 at 3:28am UTC
Feb 2, 2012 at 3:35am UTC
@daniel2012
Hope you don't mind, but I fixed up your letters, so they print correctly on screen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
// Print Statement.cpp : main project file.
#include <iostream>
#include <string>
using namespace std;
int main()
{
const string LETTER_D =
"*******\n*\t*\n*\t*\n*\t*\n*\t*\n*******\n\n" ;
const string LETTER_A =
" *******\n*\t*\n*\t*\n*********\n*\t*\n*\t*\n\n" ;
const string LETTER_N =
"* *\n* * *\n* * *\n* * *\n* * *\n* *\n\n" ;
const string LETTER_I =
"********\n *\n *\n *\n *\n********\n\n" ;
const string LETTER_E =
"********\n* \n***** \n***** \n* \n********\n\n" ;
const string LETTER_L =
"* \n* \n* \n* \n* \n********\n\n" ;
cout << LETTER_D;
cout << LETTER_A;
cout << LETTER_N;
cout << LETTER_I;
cout << LETTER_E;
cout << LETTER_L;
return 0;
}
Last edited on Feb 2, 2012 at 4:28am UTC
Feb 2, 2012 at 11:56pm UTC
Oh okay yeah that does help and i thank both of you!
but what does the \t do? havent seen that one