#include
#include <Windows.h>
#include <stdio.h>
int main(void) {
char name[16]; //名字
printf("请输入你的名字:");
scanf("%s", name);
printf("你的名字是:%s",name);
printf("\n");
system("pause");
return 0;
}
/**
第5节项目精讲-C语言风格的字符串char数组
在c语言中,字符串是以“字符数组”存储的。
#include
#include <Windows.h>
#include <stdio.h>
using namespace std;
int main(void) {
//C语言风格的字符串
char name[32];
使用C语言的函数,来处理C语言字符串
printf("请输入您的名字:");
scanf("%s", name);
printf("%s, 你好!\n", name);
// 使用C++的方式,来处理C语言字符串
cout << "请输入您的名字:";
cin >> name;
cout << name << ",你好!" << endl;
system("pause");
return 0;
}
**/