I can't figure out how to do this. I have a character array with either the name of a color or a hex code (#ffffff) and it's not returning the proper RGB values to main nor is it getting past the "#" to read the 6 hex digits. I'm really rusty and haven't coded in about a year so please criticize anything you see.

```
/**readColor()
Converts the decimal values, color name or hex value read from
the input stream to the 3 byte RGB field

Returns the rgb values if successful.  On error prints errmsg and
exits.
**/
color_t readColor(FILE *infile, char *errmsg) 
{
int rc, red, green, blue;
char alpha[7] = {};
int i=0;

rc = fscanf(infile, "%d %d %d\n", &red, &green, &blue);
if(rc == 3){
    if(red>=0 && red<=255 && green>=0 && green<=255 && blue>=0 && blue<=255){
        return((color_t){red, green, blue});
    }

}
if (rc != 0){
    printf("%s", errmsg);
    return((color_t){0,0,0});
}

fgets(alpha, 10, infile);
fputs(alpha);

i=0;
if(strcmp(alpha, "white")==0){
    return((color_t){255, 255, 255 });
}
else if(strcmp(alpha, "red")==0){
    return((color_t){255, 0, 0});
}
else if(strcmp(alpha, "blue")==0){
    return((color_t){0, 0, 255});
}
else if(strcmp(alpha, "purple")==0){
    return((color_t){128, 0, 255});
}
else if(strcmp(alpha, "black")==0){
    return((color_t){0, 0, 0});
}
else if(strcmp(alpha, "green")==0){
    return((color_t){0, 255, 0});
}
else if(strcmp(alpha, "orange")==0){
    return((color_t){255, 128, 0});
}
else if(strcmp(alpha, "yellow")==0){
    return((color_t){255, 255, 0});
}
else if(alpha[0] == "#"){
    alpha++;
    if(sscanf(alpha, "%2x%2x%2x", &red, &green, &blue)!= 3){
        printf("%s", errmsg);
    }
    else{
        return((color_t){red, green, blue});
    }
}
else{
    printf("%s", errmsg);
}

return((color_t){0, 0, 0});
}

```