I'm trying to be able to allow my program to recognize what is being entered in to the token string and compare it to the metric measurement so I can make multiple conversions like kilo, centi, etc. The problem im running into is I cant get the program to recognize milli right now.
Also note that there is a function for converting english into pig latin so ignore some of the pig latin variables
int i = 0;
int j = 0;
int command = 0, //Pig latin ints
count = 0;
double tokenNum;
char name[50];
char *tokens[10];
char *englishLength[] = {"feet"};
char *metricLength[] = {"meter", "milli", "centi", "deci", "deka", "hecto", "kilo"};
char sentence_ar[100], //Pig latin chars
*array_of_pointers_to_strings[50],
new_string1[50] = {'\0'},
new_string2[50] = {'\0'};
printf ("Enter conversion in the following format\n -- How many meters are in X feet --:\n ");
fflush (stdin);
gets(name);
printf ("Original name: %s\n", name);
tokens[0] = strtok (name, " ");
printf ("Token[0]: %s\n", tokens[0]);
i++;
while ((tokens[i] = strtok (NULL, " ")) != NULL)
{
printf ("Token[%d]: %s\n", i, tokens[i]);
i++;
}
tokenNum = atof (tokens[5]);
printf("%d\n", tokenNum);
while (j < 1)
{
if (strcmp(tokens[6],metricLength[0])==0);
{
// feet to meters
double result;
result = tokenNum * 0.3048;
j++;
printf("Feet to Meters %f\n", result);
// if you enter How many meters are in 5 feet, ANSWER: 1.524
}
// when token[6] = milli
if (strcmp(tokens[6],metricLength[1])==0)
{
//feet to millimeters
double result;
result = tokenNum * 304.8;
j++;
printf("Feet to Milli %f\n", result);
// if you enter How many milli are in 5 feet, ANSWER: 1524
}
}