I get an error I don't know about?

Hi, I've just started C++ Programming and I was looking through arrays and well, I have a 3 x 3 char array and I want to make it blank:

01  char Board[3][3];
02  char a = " ";
03   for(int i = 0; i < 3; i++)
04   {
05    for(int j = 0; j > 3; j++)
06    {
07     Board[i][j] = a;
08    }
09   }

I haven't been able to see what's wrong with this but I keep getting the msg,

Line 02: initialization to 'char' from 'const char *' lacks a cast

I'm using the Bloodshed C++ v4.01 compiler to do this (if it's important) on a windows XP platform...

I'm just wondering what's wrong? if someone could explain what's wrong along with any sort of corrections? thanks in advance...
johnnyteeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Sys_ProgConnect With a Mentor Commented:
>> char a = " ";
should be

char a = ' ' ;

Double quotes is treated as a char string in C/C++
To specify a character, use Single quotes


Amit
0
 
Sys_ProgCommented:
Also, no need to run a for loop if u are initializing the array elements with a single value
Just use this

 char Board[3][3] = { ' ' } ;


Amit
0
 
nonubikCommented:
Maybe you should do:
02 char a = ' ';  //with ' instead of "

And I think in line 05 should be j<3 instead of j>3 . Otherwise it will enter only once in your for(j) loop.
0
 
johnnyteeAuthor Commented:
oh i thank you for that. concise and well explained.
0
All Courses

From novice to tech pro — start learning today.