I hope I've commented this well enough to get a better idea of what I'm doing and trying to do.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//enum to set FALSE to 0 and TRUE to 1
enum boolean {FALSE = 0, TRUE = 1};
/*This next line is my area of confusion....I know it's not common to use it
this way, but I have to use it in the program to find if the string entered
is found in this enum list.*/
//enum strfunct {strcat, strchr, strcpy, strcmp, strlen, strstr, strtok};
int main(void)
{
int i;
enum boolean Found;
enum strfunct fct;
char string[50];
//Pointer array of String names
char *str_names[] = {
"strcat",
"strchr",
"strcmp",
"strcpy",
"strlen",
"strstr",
"strtok"
};
//get user string and compare it with string names
printf( "Enter a possible C string function: " );
gets (string);
do
{
//Initialize Found to False
Found = FALSE;
//compare and see if they're equals starting a the first element in the array
for (i=0; i<7; i++)
{
/*if statement to compare the string entered to each string name and
if it's Found it sets Found to TRUE*/
if (strcmp(string,str_names[i]) == 0)
{
//Sets Found to TRUE (1)
Found = TRUE;
}
/*else if statement to compare the string entered to each string name and
if it's NOT Found it sets Found to FALSE*/
else if (strcmp(string,str_names[i]) == 1)
{
//Sets Found to FALSE(0)
Found = FALSE;
}
}
//Display if the string name entered was an actual C String function
if (Found == TRUE)
{
printf("%s is a C defined string function\n",string);
}
//Display if the string name entered was NOT an actual C String function
else if (Found == FALSE)
{
printf("%s is NOT a C defined String function\n", string);
}
//Prompts user to enter another string and gets it
printf( "\nNext function, please: " );
gets (string);
}
//Exits if no string is entered
while (string != NULL);
return 0;
}
Code tags added by Hammer