0

Error message: "error C2181:1> illegal else without matching if

2>fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\tjeo1\my documents\visual studio 2008\projects\new\newc\exercise.cpp(3)' was matched

#include <stdio.h>
int main (void)
{
	int c;

	printf("letter=");
	c = getchar ( );

	if (('0' <= c && c <= '9') || ('A' <= && c <='F') || ('a' <= c && c <='f')){
		printf ("It is a hexadecimal\n");
	else {
		printf (" It is not a hexadecimal\n");
		}
	
	return 0;
	}

Edited by WaltP: Added CODE Tags

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by jonsca
0

Your missing a '}' in your if statement. Check right before the else.

Edited by gerard4143: n/a

0

Thanks for the reply. I have added } but still got the problem.

Error message :
1.error C2059: syntax error : '&&'
2.error C2143: syntax error : missing ';' before '{'
3. error C2181: illegal else without matching if

#include <stdio.h>
int main (void)
{
int c;

printf("letter=");
c = getchar ( );

if (('0' <= c && c <= '9') || ('A' <= && c <='F') || ('a' <= c && c <='f')){
	printf ("It is a hexadecimal\n");
}
else {
printf (" It is not a hexadecimal\n");
}

return 0;

}

Edited by WaltP: Added CODE Tags

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.