Read and Print Characters
#include <stdio.h>
main()
{
char d1, d2, d3, d4;
int x;
scanf("%d%c%c%c%c", &x,
&d1, &d2, &d3, &d4);
printf("%d%c%c%c%c", x,
d1, d3, d2, d4);
}
With input
97 354
the output is
97 534
Note that
x gets 97
d1 gets ' '
d2 gets '3'
d3 gets '5'
d4 gets '4'
This is prgram
pg71.c
.
Previous slide
Next slide
Back to first slide
View graphic version