scanf by passing char
Eg I have following c code:
printf("please input : \r\n" ) ;
char ogn, subs;
scanf("%s %s", &ogn, &subs);
printf("the two values are: %s %s", &ogn, &subs);
when running the code, eg i input "abc def" and exam ogn,subs,
I just get ogn = "ef" and subs = "def";
Can someone please explain it for me ? I know in a 'string' case a 'char
array' should be provided but here I just want to know why the 'char'
variable accepting user input causes such result ?
No comments:
Post a Comment