alright this is the revised coding. still cant get the pow function to work after including math.h. i realize im asking a lot of you guys but honestly if you dont want to help dont worry about it. its no big deal.
Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
#define NOT_FOUND -1
int
search(const char *arr[][7], const char *target[], int n);
int
main(void)
{
char c1[10], c2[10], c3[10];
int x,y,z;
double resistance;
char again;
char ColorArray[10][7] =
{"black", "brown", "red", "orange", "yellow", "green", "blue", "violet",
"gray", "white"};
do {
printf("Enter the colors of the resistor's three bands, ");
printf("beginning with the band nearest the end. ");
printf("Type the colors in lowercase letters only, NO CAPS. ");
printf("Band 1=> ");
scanf("%c", c1);
x = search(ColorArray, c1, 10);
printf("Band 2=> ");
scanf("%c", c2);
y = search(ColorArray, c2, 10);
printf("Band 3=> ");
scanf("%c", c3);
z = search(ColorArray, c3, 10);
resistance=((x*10)+y) * pow(10, z);
printf("Resistance Value>%f\n", resistance);
printf("\nDo you want to decode another resistor?(y/n)\n");
printf("=> ");
scanf("%c", &again);
} while (again == 'y' || again == 'Y');
return (0);
}
int
search(const char *arr[][7], const char *target[], int n)
{
int i, found = 0, where;
i = 0;
while (!found && i < n) {
if (strcmp(arr[i], target) == 0)
found = 1;
else
++i;
}
if (found)
where = i;
else
where = NOT_FOUND;
return (where);
}
hw5.c: In function `main':
hw5.c:29: warning: passing arg 1 of `search' from incompatible pointer type
hw5.c:29: warning: passing arg 2 of `search' from incompatible pointer type
hw5.c:33: warning: passing arg 1 of `search' from incompatible pointer type
hw5.c:33: warning: passing arg 2 of `search' from incompatible pointer type
hw5.c:37: warning: passing arg 1 of `search' from incompatible pointer type
hw5.c:37: warning: passing arg 2 of `search' from incompatible pointer type
hw5.c: In function `search':
hw5.c:61: warning: passing arg 1 of `strcmp' from incompatible pointer type
hw5.c:61: warning: passing arg 2 of `strcmp' from incompatible pointer type
Undefined first referenced
symbol in file
pow /var/tmp//ccIdtz6H.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status