Just making a program to optimize a game I encountered, which is why I didn't put much thought into it.
For some reason I cannot compare a char in a struct and a char in a char array together (one of them is a pointer?)
I get the error:
C:\Users\Unknown\Desktop\5X5 Word Game\main.cpp|71|error: ISO C++ forbids comparison between pointer and integer|
Thanks!
Code:#include <iostream> #include <fstream> #include <stdlib.h> using namespace std; struct single { char letter; bool players; }; int main() { int numWords = 160000; int maxLength = 100; char **words = new char*[numWords]; words[0] = new char[numWords*maxLength]; for ( int i = 1 ; i < numWords ; i++) { words[i] = words[i-1] + maxLength; } //Essentially: words[160000][100] ifstream ifs("en-US.dic", ios::in); for(int a = 0; a<numWords; a++) { ifs >> words[a]; //cout << words[a] << endl; } single Grid[25]; single tempGrid[25]; for(int a = 0; a<25; a++) { Grid[a].letter = 0; Grid[a].players = false; } string tempAllLetters; cout << "Enter all letters: "; cin >> tempAllLetters; for(int b = 0; b<25; b++) { Grid[b].letter = tempAllLetters[b]; } bool check; for(int a = 0; a<numWords; a++) //each cycle checks if each word is possible { for(int b = 0; b<25; b++) { tempGrid[b].letter = Grid[b].letter; } for(int b = 0; b<25; b++) { check = false; for(int c = 0; c<25; c++) { if(words[b] == tempGrid[c].letter && words[b] != 0) { // check = true; // tempGrid[c].letter = 0; // tempGrid[c].players = true; } } if(check == false) { break; } } } return 0; }