How do I combine two c-style strings together?

Basically I'm trying to see if the first letter is in the dictionary... then if it is.. check if the first and second letter are in the dictionary.. and if it is... check if the first, second, and third letter are in the dictionary... and so on and so forth.

I'm just displaying the code I'm having trouble with. The rest of the code works I'm just having trouble with the line 8 if statement. I know I'm using strncat wrong (never used it before). Idk if I'm correctly using it.

Edit: I cannot use strings. Only C-Style Strings.

void checkSecondLetter(char boggleBoard[6][6], char firstLetter){
char secondLetter[3];
for(int checkRow = 0; checkRow < 6; checkRow++)
for(int checkColumn = 0; checkColumn < 6; checkColumn++)
for(int checkDictionary = 0; checkDictionary < MaxNumberOfWords; checkDictionary++){
secondLetter[0] = firstLetter;
secondLetter[1] = boggleBoard[checkRow][checkColumn];
if (strncat(secondLetter[0], secondLetter[1]) == *theWords[checkDictionary])
cout << "The word is " << secondLetter[0] << secondLetter[1] << endl;
}
}
void checkFirstLetter(char boggleBoard[6][6]){
char firstLetter;
for(int checkRow = 0; checkRow < 6; checkRow++)
for(int checkColumn = 0; checkColumn < 6; checkColumn++)
for(int checkDictionary = 0; checkDictionary < MaxNumberOfWords; checkDictionary++){
if (boggleBoard[checkRow][checkColumn] == *theWords[checkDictionary]){
firstLetter = boggleBoard[checkRow][checkColumn];
boggleBoard[checkRow][checkColumn] = '*';
checkSecondLetter(boggleBoard,firstLetter);
}
}
}

See answers to your other thread here

You call strcmp() to compare two character arrays, == doesn't work like it does for std::string class. To solve your problem you will have to first combine the two characters like I showed you in your other thread and then call strcmp() to compare it with another character array. Can't be done all in the same code statement.

This article has been dead for over six months. Start a new discussion instead.