此代码展示了结构体、指针、输入输出、循环控制、条件语句、变量类型等基本概念的应用。
#include <stdio.h>
#include <stdlib.h> // 为了使用system()函数
#include <string.h> // 为了使用strcpy()函数
struct Xinxi {
char name[50];
int age;
char sex[14];
long long tele;
char qianming[50];
};
void XiuGaiXinXi(struct Xinxi *s) {
int choice;
char ChuCun[50]; // 临时存储修改后的字符串输入
do {
printf("\n请选择要修改的信息项(1: 姓名, 2: 年龄, 3: 性别, 4: 电话号码, 5: 个性签名, 0: 完成修改):");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("请输入新的姓名:");
scanf("%49s", s->name);
break;
case 2:
printf("请输入新的年龄:");
scanf("%d", &s->age);
break;
case 3:
int xingbiexuanze;
printf("请输入新的性别(1: 男, 2: 女, 3: 沃尔玛购物袋, 4: 武装直升机,5:海参,6:哥布林):");
scanf("%d", &xingbiexuanze);
switch (xingbiexuanze) {
case 1: strcpy(s->sex, "男"); break;
case 2: strcpy(s->sex, "女"); break;
case 3: strcpy(s->sex, "沃尔玛购物袋"); break;
case 4: strcpy(s->sex, "武装直升机"); break;
case 5: strcpy(s->sex, "海参"); break;
case 6: strcpy(s->sex, "哥布林"); break;
default:
printf("无效的性别选项,已保持原样。\n");
break;
}
break;
case 4:
printf("