So, i have to create a program to work with a menu and run differect functions with different letters used as commands, but I cant get my program to correctly Identify if a menuinput is the same as a letter or the other.

Here I keep using the letter L for input but I can't seem to get the if statement to recognized that it is the same as what is in the statement.

#include <stdio.h>
#include <string.h>


int main()
{
	// setting up array and a few integers i may need//
	unsigned char imgSet[10][65538] = {0} ;
	//char *input;
	char inputarray[2];
	char *menu;
	char l,L,r,R,a,A,h,H,v,V,t,T,d,D,m,M,q,Q;
	char menuinput=0;
	int i,vSize, hSize;
	

	
	//setting the menu to a pointer
	//while(menuinput != ('q' || 'Q'))
	//{
	menu = "*****OPTION*****MENU***** \nL: Load image \nR: Remove image \nP: Print image \nA: Average image \nH: Horizontal derivative\nV: Vertical derivative\nT: compute hisTogram\nD: search Digram\nM: local Maxima\nQ: Quit program\n*************************\n\n";
	printf("%s", menu );
	
	printf("enter option\n:");
	scanf("%c", &menuinput);
	printf("Input is %c \n",menuinput);
	

	l = 'l';
	L = 'L';
	if(menuinput == (l || L))
		printf("input is %c\n",menuinput);
	else
		printf("This isn't L\n");
	printf("menuinput is %c\n",menuinput);
	
	//}




}

Where did you learn that if(menuinput == (l || L)) is a valid IF statement? You need to look up how a compound statement is written.

And what's the purpose of assigning l = 'l'; and L = 'L'; just to use variables in the IF statement? Use the characters themselves.

Where did you learn that if(menuinput == (l || L)) is a valid IF statement? You need to look up how a compound statement is written.

Well forgive my ingratitude, but I kind of knew about the characters. That was just the result of frustration and tinkering. I rewrote the compound statement to

if((menuinput == l) ||(menuinput == L))

and works now. Thanks

This article has been dead for over six months. Start a new discussion instead.