Okay so i'm trying to make a "read character" function that would only take upper or lower-case letters, not accents (i'm french so it's important with french keybords) and return it upper-cased. For that i made another source file for the readcharacter function:
char readCharacter()
{
char character;
do
{
printf("Please enter a letter without accents and hit 'enter': ");
character = getchar();
while(getchar() != '\n');
printf("\n");
character = toupper(character); //Upper-case if lower case
} while(((character < 65)||(character > 90)));
return character;
}
Here's my main:
#include "main.h"
int main(void)
{
char MyLetter = readCharacter();
char MyLetter2 = readCharacter();
printf("%c\n%c\n", MyLetter, MyLetter2);
}
My problem is, i got this as output:
S
l
Please enter a letter without accents and hit 'enter':
Please enter a letter without accents and hit 'enter':
S
L
Why don't i get this?
Please enter a letter without accents and hit 'enter':S
Please enter a letter without accents and hit 'enter':l
S
L
Don't know if this is relevant, but my IDE is eclipse and compiler is MinGW (gcc?) Sorry for bad english and/or bad coding... i've just started coding... Thx!