putchar()
1 1,#include<iostream> 2 using namespace std; 3 int main() 4 { 5 char c1, c2; 6 cout << "请输入两个字符c1,c2:"; 7 c1 = getchar(); 8 c2 = getchar(); 9 cout << "用putchar输出的结果:"; 10 putchar(c1); 11 putchar(c2); 12 cout << endl; 13 cout << "用cout语句输出的结果为:"; 14 cout << c1 << c2 << endl; 15 system("pause"); 16 return 0; 17 } 18 2,#include <iostream> 19 using namespace std; 20 int main() 21 { 22 char c1, c2; 23 cout << "请输入两个字符c1,c2:"; 24 c1 = getchar(); //将输入的第一个字符赋给c1 25 c2 = getchar(); //将输入的第二个字符赋给c2 26 cout << "用putchar函数输出结果为:"; 27 putchar(c1); 28 putchar(44); 29 putchar(c2); 30 cout << endl; 31 cout << "用cout语句输出结果为:"; 32 cout << c1 << "," << c2 << endl; 33 system("pause"); 34 return 0; 35 } 36 3,