#include <stdio.h>

#ifndef __CHARCODES__
#define __CHARCODES__
#define LETTER      1
#define NUMBER      2
#define SYMBOL      3
// sub-type codes
#define VOWEL       4
#define CONSONANT   5
#define ODD         6
#define EVEN        7
#define UPPER_ASCII 8
#define LOWER_ASCII 9
#endif

int main() {
	char keyStroke = 0;
	int typeCode = -1, subTypeCode = -1;
	int CHARCODES = 0;
	
	
		printf("Please enter a Character\n");
	scanf("%c", &keyStroke);

		if(keyStroke >= 48 && keyStroke <= 57); {
			CHARCODES = NUMBER;
		}
		
		if(keyStroke = 49 || 51 || 53 || 55 || 57); {
			CHARCODES = ODD;
		}
		if else (keyStroke) {
			CHARCODES = EVEN;
		}
		
		printf(" The character you entered was %c\n", keyStroke);

		if(keyStroke) >= 65 && keyStroke <= 90 || keyStroke >= 97 && keyStroke <= 122); {
			CHARCODES = LETTER;
		}
		if else(keyStroke) = 65 || 97 || 69 || 101 || 73 || 105 || 79 || 111 || 85 || 117); {
			CHARCODES = VOWEL;
		}
		else (keyStroke) {
			CHARCODES = CONSONANT;
		}

		printf("The character you entered was %c\n", keyStroke);
		
		
		if (keyStroke) >= 32 && keyStroke <= 46 || keyStroke >= 58 && keyStroke <= 65 || keyStroke >= 128 && keyStroke <= 255); {
			CHARCODES = SYMBOL;
		}
		if else (keyStroke) >= 128 && keyStroke <= 225); {
			CHARCODES = LOWER_ASCII;
		
		else (keyStroke) >= 32 && keyStroke <= 47 || keyStroke >= 58 && keyStroke <= 64); {
			CHARCODES = UPPER_ASCII;
		}
		printf("The character you entered was %c\n", keyStroke);

		
	
	

	return 0;

		}

I compile and get errors that i do not have a matching if with my else. what is wrong?

Edited 7 Years Ago by geoffy0404: n/a

Every one of your if-statements is wrong. The syntax is supposed to be:

if ( <condition> ) {
   <code>
}

Yours is:

if ( <condition> ); { // Get rid of that semi-colon
   <code>
}

Also, lines 39, 42, 55, and 58 need some serious rewriting, and please, indent your code correctly.

Edited 7 Years Ago by William Hemsworth: n/a

if else(keyStroke) = 65 || 97 || 69 || 101 || 73 || 105 || 79 || 111 || 85 || 117

You can't do that, you would have to do:

else if ( keyStroke == 65 || keyStroke == 97 /* ect */ ) {
   <code>
}

In fact, just start over and read this. [link]

Edited 7 Years Ago by William Hemsworth: n/a

OKay here is the edit, where i pretty much think i fixed it up to the way you showed me, i hope i can get some responce cause im still getting an error.. thank you

#include <stdio.h>

#ifndef __CHARCODES__
#define __CHARCODES__
#define LETTER      1
#define NUMBER      2
#define SYMBOL      3
// sub-type codes
#define VOWEL       4
#define CONSONANT   5
#define ODD         6
#define EVEN        7
#define UPPER_ASCII 8
#define LOWER_ASCII 9
#endif

int main() {
	char keyStroke = 0;
	int typeCode = -1, subTypeCode = -1;
	int CHARCODES = 0;
	
	
		printf("Please enter a Character\n");

		scanf("%c", &keyStroke);

		if (keyStroke) >= 48 && keyStroke <= 57; {

		CHARCODES = NUMBER;
		}
		
		if (keyStroke) = keyStroke == 49 || keyStroke == 51 || keyStroke == 53 || keyStroke == 55 || keyStroke = 57); {

		CHARCODES = ODD;
		}
		if else (keyStroke) {

		CHARCODES = EVEN;
		
		
		printf(" The character you entered was %c\n", keyStroke);
		}

		if (keyStroke) >= 65 && keyStroke <= 90 || keyStroke >= 97 && keyStroke <= 122; {

		CHARCODES = LETTER;

		printf(" The character you entered was %c\n", keyStroke);

		}
		if else (keyStroke) = keyStroke == 65 || keyStroke == 97 || keyStroke == 69 || keyStroke == 101 || keyStroke == 73 || keyStroke == 105 || keyStroke == 79 || keyStroke == 111 || keyStroke 85 || keyStroke == 117; {
		
		CHARCODES = VOWEL;

		printf(" The character you entered was %c\n", keyStroke);
		}
	
		else (keyStroke) {
		
		CHARCODES = CONSONANT;
		
		printf("The character you entered was %c\n", keyStroke);
		}
		
		if (keyStroke) >= 32 && keyStroke <= 46 || keyStroke >= 58 && keyStroke <= 65 || keyStroke >= 128 && keyStroke <= 255; {

		CHARCODES = SYMBOL;

		printf(" The character you entered was %c\n", keyStroke);
		}
		
		if else (keyStroke) >= 128 && keyStroke <= 225; {

		CHARCODES = LOWER_ASCII; 

		printf(" The character you entered was %c\n", keyStroke);
		}
		
		else (keyStroke) >= 32 && keyStroke <= 47 || keyStroke >= 58 && keyStroke <= 64; {

		CHARCODES = UPPER_ASCII;
		
		printf("The character you entered was %c\n", keyStroke);
		}

		

	return 0;

		}

Edited 7 Years Ago by geoffy0404: n/a

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