lundi 30 mars 2015

Validation of data with char

I'm looking for a valid condition to check if the user is writing a char or not. I was trying with (n!=char), but this is clearly not possible in C right?


this is what I have:



char n;
do
{
printf("Introduce a caracter\n");
scanf("%c", &n);
if(n!=char)
printf("Error! The caracter you introduced is not valid.\n");
}
while(n!=char);

return n;

Aucun commentaire:

Enregistrer un commentaire