To add to the 'gems' Chuck found, there appears to be a thorough lack of understanding of io streams. E. g. when you look at the function
draw()
:
void draw(char main[][75], int score)
{
system("cls");
cout<<"Score : %d\n"<<score; for (int x = 0; x < 23; x ++)
{
for (int y = 0; y < 75; y ++)
{
cout << "%c"<< main[x][y]; }
cout<<"\n"; }
}
1. you seem to be mistaking output streams for
printf()
. String formatting for output streams is entirely different! There is no need to specify the type of a variable, as it is automatically derived! So just omit the '%d' in your output string, or else it will be printed, literally.
Also, the end of line character at the end will be printed with the rest of the string, before the score. I doubt that was your intention. (also see 3.)
2. same as one, and in addition you'll scramble your output with countless outputs of the string, '%c'. Just remove that string -
main[x][y]
is of type
char
and will be printed as such just fine.
3. while forcing a line break like this will work on most systems, some systems use different symbols for a line break. Therefore it is better style to instead use the constant
std::endl
(for end-line)
Here is the fixed version:
void draw(char main[][75], int score)
{
system("cls");
cout<<"Score : "<<score << endl;
for (int x = 0; x < 23; x ++)
{
for (int y = 0; y < 75; y ++)
{
cout << main[x][y];
}
cout<<endl;
}
}