Otsil
Otsil

Reputation: 3

Error "does not name a type"

Hello i have errors in part of my program:

    char *wt1,*wt2,*wt3,*wt4,*wt5,*wt6,*wt7,*wt8,*wt9;
char tablica[3][3]{'*','*','*','*','*','*','*','*','*'};

void menu();
void mapa();    
void sprawdz();
char wyborgracza();
char wyborkomputera();
char ruchG();
char ruchK();
int  r1, t, wybor,
*r1_ ;


wt1=&tablica[0][0];                                                     
wt2=&tablica[0][1];
wt3=&tablica[0][2];
wt4=&tablica[1][0];
wt5=&tablica[1][1];
wt6=&tablica[1][2];
wt7=&tablica[2][0];
wt8=&tablica[2][1];
wt9=&tablica[2][2]; 

I have 9 errors, everyone like it

[Error] 'wt1' does not name a type

It is my first program and i don't know what i did wrong, i tried find the cause but i didnt. These declaration must have to be here, before any function, because i need it for more part of this program :l

Upvotes: 0

Views: 222

Answers (1)

Luchian Grigore
Luchian Grigore

Reputation: 258678

You can't do assignments like that at namespace scope, but you can initialize the variables:

char* wt1 = &tablica[0][0];
char* wt2 = &tablica[0][1];
//....

Upvotes: 4

Related Questions