I have the following function
int namecomp(char c);
Part of the function code
else if (c == 'b' || 'B')
i=2;
The way I am calling it in main()
j= namecomp(s);
and s is defined as char s = 'B';
There is an error and whenever I am trying to use j the value is always 1 in the main. Please help me to know where exactly the error is. Thanks!
EDIT:Sorry Folks none of it worked., I am posting the complete code for help
int main (int argc, char* argv [])
{
int i;
int j;
char s = 'B';
j= namecomp(s);
printf ("%d",j);
}
int namecomp(char c)
{
int i;
if (c == 'a'||'A')
i=1;
else if ((c == 'b' || c == 'B'))
i=2;
return i;
}
always evaluates to
1, because it’s parsed asI’m betting you want