Hi, I'm pretty new at programming and I'm getting into linked lists. As part of a word database type thing I'm writing a function searchWord that calls a function named searchNodeWord . searchNodeWord runs through a singly linked list and assigns the value of the correct node (based on a parameter called strKey) to a parameter called pResult. searchWord should then print one of the strings in the node stored in pResult.
I't works fine until I try to printf the string in the pResult in [i]searchWord[\i]. I can use printf while I'm still in searchNodeWord just to see that I got the right node, but I can't seem to use it outside of the function. The compiler gives me a "Dereferencing pointer to incomplete type" error at that point.
Here's the relevant code:
void searchNodeWord(sWordType *pFirst, string50 strKey, sWordType **pResult)
sWordType *pRun = NULL; //sWordType is the typedef i use for my nodes
pRun = pFirst;
char cChoice = '0';
int nLoop = 1;
if( pRun && strcmpi(pRun->strWord, strKey) == 0 )
printf("Match Found: \n");
printf("Entry: %s\n", pRun->strWord);
printf("Translation: %s\n", pRun->strTrans);
printf("\nIs this the correct entry? (Y/N)");
if( cChoice == 'N' || cChoice == 'n' )
pRun = pRun->pNext;
else if ( cChoice == 'Y' || cChoice == 'y' )
*pResult = pRun;
printf("-->%s\n", (*pResult)->strWord); //This works fine
nLoop = 0;
//some other irrelevant code follows
Can anyone tell me why I cant seem to use that address fromm outside of searchNodeWord?
void searchWord(sWordType *pFirst) //pFirst points to the head of a singly linked list
string50 strKey; //typedef char string50
sWordType *pResult = NULL; //sWordType is the typedef i use for my nodes
printf("Current lexicon entires:\n");
displayList(pFirst); //Lists all available entries in linked list
printf("Enter word to search: ");
searchNodeWord(pFirst, strKey, &pResult); //pResult should be updated to proper address
//ERROR OCCURS AT NEXT LINE
Thanks in advance.