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);
                }
            }
}

A C string is and array of char. It is zero terminated, that is the last char in the string (but not necessarily the array) is the ASCII nul or '\0' or plain 0 (different names for the same thing).

All characters up to the zero terminator must be printable characters.

You have an array of char char secondLetter[3]; at line 6 and 7 you set the first 2 characters of that string, to make if a C string all you have to do is set secondLetter[2] tp '\0', secondLetter[2] = '\0';.

strcat is for concatinating 2 C strings but you have passed it 2 char, anyway there is no need for it you already have your string in secondLetter. You can not compare C strings with == you will compare the pointers and they are unlikely to be the same. To compare C strings you need to call strcmp or strncmp from the header 'cstring'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.