samedi 20 août 2016

Single Character input in c language in ubuntu

I just came across this:

#include <stdio. h>

int main() 
{
 char fname,sname;
 printf("your first name?: ");
 flushall();
 scanf("%c", &fname);
 printf("your last name?: "); 
 scanf("%c", &sname);
 printf("initials: %c.   %c",fname,sname);

return 0;
} 

Problem is I'm getting printf statements and m unable to input anything.

It just skips the input part...

P.S.: I'm using ubuntu 15.10 and used fflush(stdin) and fpurge() but none of them worked.

Aucun commentaire:

Enregistrer un commentaire