#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
int main()
{
bool flag= true;
int menu_option;
char first_band [16], second_band [16], third_band [16], fourth_band [16], green[16];
while (flag)
{
printf("Please choose an option:\n");
printf("To run the program, enter 1.\n");
printf("For help, enter 2.\n");
printf("To exit, enter 3.\n");
scanf("%i", &menu_option);
switch (menu_option)
{
case 1:
printf("Please enter the colour of the first band on the resistor:\n");
scanf(" %s", first_band);
printf("Please enter the colour of the second band on the resistor:\n");
scanf(" %s", second_band);
printf("Please enter the colour of the third band on the resistor:\n");
scanf(" %s", third_band);
printf("Please enter the colour to fourth band ont he resistor. If there is no fourth band, enter 'null'.\n");
scanf(" %s", fourth_band);
flag=false;
break;
case 2:
flag=true;
printf("program instructions");
break;
case 3:
flag=false;
return 0;
break;
default:
flag=true;
printf("Invalid command.\n");
break;
}
}
printf("%s", first_band);
if (first_band == "green")
printf("the first band is %c\n", first_band);
return (0);
}
So i can't get the last "if" statement to print "the first band is %s". the print statement right above it is to see if the program is even reading the user input...which it seems to be. It just won't seem to recognize the word and execute the if statement. I feel like my syntax is wrong when dealing with the char strings, which is causing this problem, but I'm new to this so a helping hand would be much appreciated.