一.输入输出
1.scanf、printf、getchar和putchar的用法:
一个小练习解决问题:
#include<stdio.h>
int main()
{
char c1,c2,c3,c4,c5;
scanf("%c%c%c%c%c",&c1,&c2,&c3,&c4,&c5);
printf("加密前的密码:%c%c%c%c%c\n",c1,c2,c3,c4,c5);
puts("加密前的密码:");
putchar(c1);
putchar(c2);
putchar(c3);
putchar(c4);
putchar(c5);
printf("\n加密后的密码:%c%c%c%c%c\n",c1+4,c2+4,c3+4,c4+4,c5+4);
puts("加密后的密码:");
putchar(c1+4);
putchar(c2+4);
putchar(c3+4);
putchar(c4+4);
putchar(c5+4);
return 0;
}
补充:
getchar和putchar是函数调用,且一次只能输入或输出一个字符。
scanf和printf输入输出的类型多。
scanf用到的是参数的地址,所以要用到&(取地址符)。