I split a sentence into a word per line, now I want to compare word to a word in file
Here's my code:
Code:
#include <stdio.h>
#include <string.h>
int main ()
{
char b[256];
char * pch;
printf("Input a short sentence: ");
gets(b);
pch = strtok (b," ,.-");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " ,.-");
}
getch();
return 0;
}
Here's my results:
Input a short sentence: dog ran
dog
ran
___________
I want the result to read like this though:
Input a short sentence: dog ran
dog: Noun
ran
How I want to add ': Noun' to 'dog' is to open a file, and read from that file that dog is a noun, then print this on the console screen.
I looked up how on a reference library but didn't see anything that would do this, there was something for c++ but I don't understand C++ at all.