Salve a tutti avrei bisogno di una mano con il codice del giochino del tris che sto facendo in c++. Ricevo un errore in fondo al codice che non riesco proprio a capire:
Alla riga Z ricevo questo errore: ISO C++ forbids comparison between pointer and integer.codice:#include <cstdlib> #include <iostream> using namespace std; void stampa (char t[3][3]) { cout <<" _ _ _ \n"; cout <<" | "<< t[2][0]<< " | "<< t[2][1]<< " | "<< t[2][2]<< " | \n"; cout <<" | "<< t[1][0]<< " | "<< t[1][1]<< " | "<< t[1][2]<< " | \n"; cout <<" | "<< t[0][0]<< " | "<< t[0][1]<< " | "<< t[0][2]<< " | \n"; } bool vittoria (char t[3][3]) { for (int i=0; i<3; i++) { if ((t[i][0]!=' ') && (t[i][0]==t[i][1]) && (t[i][0]==t[i][2])) return true; for (int j=0; j<3; j++) if ((t[0][j]!=' ') && (t[0][j]==t[1][j]) && (t[1][j]==t[2][j])) return true; if ((t[0][0]!=' ') && (t[0][0]==t[1][1]) && (t[0][0]==t[2][2])) return true; if ((t[2][0]!=' ') && (t[2][0]==t[2][1]) && (t[2][0]==t[2][2])) return true; return false; } } bool valido (int r, int c, char t[3][3]) { if (r<0 || r>2) return false; if (c<0 || c>2) return false; if (t[r][c]!= ' ') return false; return true; } int gioco () { char t[3][3]={{' ',' ',' '}, {' ',' ',' '}, {' ',' ',' '}}; int r,c; stampa(t); for (int i=0; i<9; i++) { do { cout<<" Giocatore ";//(i%2==0)?1;2 cin>> r>> c; } while (r,c,t!=valido); // RIGA Z t[r][c]=(i%2==0)?'X':'O'; stampa (t); if (vittoria (t)) { cout<< " Hai vinto!\n"; break; } if (i==9) cout<< " Pari!\n"; } }
Potete aiutarmi, grazie![]()

Rispondi quotando