I'm suppose to make a code that is suppose to check errors on inputted letters but I can't seem to get it right cause when I input something either wrong or right it still prints "ERROR"

void check(char a, char b, char c, char d,char e,char f, char g, char h)
{
if void check(char a, char b, char c, char d,char e,char f, char g, char h)
{
if (a==a||b==b||c==c||d==d)
printf("same letter \n");
else if(a&&b&&c&&d != 'a','b','c','d','e','g','l','m','p','r','s','t');
printf("wrong letter \n");
}
}

the characters a,b,c &d are suppose to be the inputted code. I'm not suppose to let it input same letters like aabc, the second one is suppose to print "wrong letter" if the letters inputed are not a,b,c,d,e,g,l,m,p,r,s&t. My problem is any code I input it just prints both "same letter" & "wrong letter". Any help is appreciated :)

Sorry wrong code .

void check(char a, char b, char c, char d,char e,char f, char g, char h)
{
if (a==a||b==b||c==c||d==d)
printf("same letter \n");
else if(a&&b&&c&&d != 'a','b','c','d','e','g','l','m','p','r','s','t');
printf("wrong letter \n");
}

Edited 5 Years Ago by ineedsomehelp:3: n/a

if (a==a||b==b||c==c||d==d) When is the variable a ever not equal to the variable a?
When is the variable b ever not equal to the variable b?
When is the variable c ever not equal to the variable c?
When is the variable d ever not equal to the variable d? else if(a&&b&&c&&d != 'a','b','c','d','e','g','l','m','p','r','s','t'); Look up the syntax for the IF statement.

Edited 5 Years Ago by WaltP: n/a

{
if (a==b||a==c||a==d||b==c||b==d||c==d);
printf("same letter \n");
if(a!='a'||b!='a'||c!='a'||d!='a'||a!='b'||b!='b'||c!='b'||d!='b'||a!='c'||b!='c'||c!='c'||d!='c'||a!='d'||b!='d'||c!='d'||d!='d'||a!='e'||b!='e'||c!='e'||d!='e'||a!='g'||b!='g'||c!='g'||d!='g'||a!='l'||b!='l'||c!='l'||d!='l'||a!='m'||b!='m'||c!='m'||d!='m'||a!='p'||b!='p'||c!='p'||d!='p'||a!='r'||b!='r'||c!='r'||d!='r'||a!='s'||b!='s'||c!='s'||d!='s'||a!='t'||b!='t'||c!='t'||d!='t');
printf("wrong letter \n");
}

it is still not working. Any suggestions on what I did wrong? :| I can compile it but the results are the same.

Edited 5 Years Ago by ineedsomehelp:3: n/a

it is still not working. Any suggestions on what I did wrong? :| I can compile it but the results are the same.

Are you kidding with this? Can't you figure out a better, more readable way to accomplish this?

{
if (a==b||a==c||a==d||b==c||b==d||c==d);
                                       ^ what does this do?
printf("same letter \n");
if(a!='a'||b!='a'||c!='a'||d!='a'||a!='b'||
   b!='b'||c!='b'||d!='b'||a!='c'||b!='c'||
   c!='c'||d!='c'||a!='d'||b!='d'||c!='d'||
   d!='d'||a!='e'||b!='e'||c!='e'||d!='e'||
   a!='g'||b!='g'||c!='g'||d!='g'||a!='l'||
   b!='l'||c!='l'||d!='l'||a!='m'||b!='m'||
   c!='m'||d!='m'||a!='p'||b!='p'||c!='p'||
   d!='p'||a!='r'||b!='r'||c!='r'||d!='r'||
   a!='s'||b!='s'||c!='s'||d!='s'||a!='t'||
   b!='t'||c!='t'||d!='t');
                          ^ what does this do?
printf("wrong letter \n");
}

Edited 5 Years Ago by WaltP: n/a

the first

if (a==b||a==c||a==d||b==c||b==d||c==d);

is suppose to check if 1st entered char which is stored in a, is not suppose to have tha same char as the other entered char which is stored in b,c and d respectively.and print "same letter" if a matches with b ,a matches with c etc.

while the second one

if(a!='a'||b!='a'||c!='a'||d!='a'||a!='b'||   b!='b'||c!='b'||d!='b'||a!='c'||b!='c'||   c!='c'||d!='c'||a!='d'||b!='d'||c!='d'||   d!='d'||a!='e'||b!='e'||c!='e'||d!='e'||   a!='g'||b!='g'||c!='g'||d!='g'||a!='l'||   b!='l'||c!='l'||d!='l'||a!='m'||b!='m'||   c!='m'||d!='m'||a!='p'||b!='p'||c!='p'||   d!='p'||a!='r'||b!='r'||c!='r'||d!='r'||   a!='s'||b!='s'||c!='s'||d!='s'||a!='t'||   b!='t'||c!='t'||d!='t');

is suppose to check if the letters a,b,c and d does not contain letters that are not a,b,c,d,e,g,l,m,p,r,s or t. and print "wrong letter" if the letters are not a,b,c,d,e,g,l,m,p,r,s or t. The problem is still the same as my 1st post here so I was wondering what I did wrong. btw Thanks for the reply.

This question has already been answered. Start a new discussion instead.