Code:
#include <stdafx.h>
#include <stdio.h>
#define STRING 8
#define error -1
int
main(void)
{
char COLOR_CODES[10][8] = {"black", "brown", "red",
"orange", "yellow", "green", "blue", "violet", "gray",
"white"};
char color1[STRING],
color2[STRING],
color3[STRING];
char holder;
int a, b, c;
printf("Enter the colors of the resistor's three bands, beginning with\nthe band nearest the end. Type the colors in lowercase letters\nonly, NO CAPS.\nBand 1 => ");
scanf("%s", color1);
printf("\nBand 2 => ");
scanf("%s", color2);
printf("\nBand 3=> ");
scanf("%s", color3);
[b]if (color1 = "black")
a = 1;
if (color1 = "brown")
a = 2;[/b]
printf("\n%f", &a);
return (0);
}
I don't really know what I'm doing, but I'm trying to test to see if color1 equals certain colors. But I get an error when I try. Why can't I type if (color1 = "brown") a = 2;, etc.??? And how can I do that?