When i call the function read() without putting a loop or something like that before it works perfectly but when i add some code it doesn't work, here is the code :
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char read();
int main()
{
    int level = -1;
    char c;
    while (level < 1 || level > 3)
    {
        printf("Select a level 1/2/3 : ");
        scanf("%d", &level);
    }
    printf("Put a character : ");
    c = read();
    printf("Your character : %c", c);
    
    return 0;
}
char read()
{
    char letter;
    letter = getchar();
    letter = toupper(letter);
    while (getchar() != '\n');    
    return letter;
}
 
    