#include <stdio.h> int main(void) { int i,r; char c; puts("Type 123(LF)"); r=scanf("%d", &i); printf("i=%d r=%d\n", i, r); puts("Type 123A(LF)"); r=scanf("%d", &i); printf("i=%d r=%d\n", i, r); r=scanf("%c", &c); printf("c=%c r=%d\n", c, r); puts("Type 123 A(LF)"); r=scanf("%d %c", &i, &c); printf("i=%d c=%c r=%d\n", i, c, r); puts("Type 123 A(LF)"); r=scanf("%d %c", &i, &c); printf("i=%d c=%c r=%d\n", i, c, r); puts("Type 123(LF)"); r=scanf("%d%c", &i, &c); printf("i=%d c=%c r=%d\n", i, c, r); }
“%d\n” –> must provided with \n
Type 123(LF) 123 i=123 r=1 Type 123A(LF) 123A i=123 r=1 c=A r=1 Type 123 A(LF) 123 A i=123 c=A r=2 Type 123 A(LF) 123 A i=123 c=A r=2 Type 123(LF) 123 i=123 c= r=2
r=1 : 1 item is processed
r=2: 2 items are processed