Sekacorn
Sekacorn

Reputation: 29

I am having an error that I do not understand.

I am getting error saying i am missing a terminating and not to mention that i am missing an ';" at grid[bl][cl]=(char)'\';

int bl= rand()%MAXROWS;
int cl= rand()%MAXCOL;
int dir = rand()%2;
if(dir==0){
    grid[bl][cl]= (char) '\';

}
else
    grid[bl][cl]='/';

Upvotes: 3

Views: 45

Answers (1)

πάντα ῥεῖ
πάντα ῥεῖ

Reputation: 1

The backslash \ character actually escapes the following ' character, so you are leftover with an unclosed literal. You can fix it by writing

grid[bl][cl]= (char) '\\';
                   // ^

The backslash character is used to escape itself.

Upvotes: 3

Related Questions