Whilst this is valid C, it's likely to not be particularly useful. ppart here would be the location on of the array, which may or may not be "greater than zero" (because pointers converted to integer is a signed value, and if it so happens that the address has the highest bit set, it will be negative - for example in Linux this would be the case, because the stack starts at just under 3GB, which is over the 2GB "sign" barrier) - but it certainly won't change once the ppart has been created. If you don't follow that, just take the fact that "the above code doesn't do anything meaningful", and if you can't figure out how to do something useful instead, explain what you meant to do, and we will explain how to do that.
Next, aside from a chain of strcmp(), a possible solution would be:
Code:
struct pair
{
char *part;
char *word;
} pairs[maxparts] = {
{ "noun1", "Light" },
{ "verb", "Walking" },
{ "adjective", "Dark" },
{ "color", "Blue" },
{ "sound", "Quiet" },
{ "simile", "Paths like tree farm rows" },
{ "emotion", "Strong lonliness" },
{ "noun2", "Grass" }
};
const int maxparts = sizeof(pairs) / sizeof(pairs[0]);
int main()
{
int i;
....
for(i = 0; i < maxparts; i++)
{
if (strcmp(pairs[i].part, ppart) == 0)
{
printf("%s\n", pairs[i].word);
break; // Found it.
}
}
...
Also, in your code, you have the printf to ask for a part and the scanf to read it in swapped around.
--
Mats