c语言中%11s是什么意思,C 11标准中该声明的含义是什么?

从C 11标准第5.2.2 / 1段中提取的句子中粗体字符是什么意思?

There are two kinds of function call: ordinary function call and member function (9.3) call. A function call is a postfix expression followed by parentheses containing a possibly empty,comma-separated list of expressions which constitute the arguments to the function. For an ordinary function call,the postfix expression shall be either an lvalue that refers to a function (in which case the function-to-pointer standard conversion (4.3) is suppressed on the postfix expression),or it shall have pointer to function type.

编辑

基本上我要问的是:当标准说“(在这种情况下,函数到指针标准转换在后缀表达式上被抑制)”这是否意味着这种抑制是好的或者它将在以后被撤销(例如,在函数重载之后)?

EDIT1

在我看来,上面的“抑制”一词具有误导性,因为它给人的印象是,从函数名到函数指针的转换可能永远不会被编译器完成.我相信情况并非如此.在函数重载过程完成后,此转换将始终发生,因为只有在此时,编译器才能确切地知道要调用的函数.程序初始化函数指针时不是这种情况.在这种情况下,编译器知道要调用的函数,因此不会出现重载,如下例所示.

#include

int foo(int i) { std::cout << "int" << '\n'; return i * i; }

double foo(double d) { std::cout << "double" << '\n'; return d * d; }

int main()

{

int(*pf)(int) = foo; // no overloading here!

std::cout << pf(10.) << '\n'; // calls foo(int)

std::cout << foo(10.) << '\n'; // call foo(double) after function overloading. Therefore,only after function

// overloading is finished,the function name foo() is converted into a function-pointer.

}

代码打印:

int

100

double

100

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include <stdlib.h> #include <string.h> typedef struct user { char name[20]; char password[20]; char phone[12]; struct user* next; }user; user* head = NULL; //从文件录入链表(加载数据) void load_from_file() { FILE* fp = fopen("user.date", "r"); if (!fp) { return ; } char name[20]; char password[20]; char phone[12]; while (fscanf(fp, "%19s %19s %11s", name, password, phone) == 3) { user*n= (struct user*)malloc(sizeof(user)); strcpy(n->name, name); strcpy(n->password, password); strcpy(n->phone, phone); n->next = head; head = n; } fclose(fp); } //新用户注册 void register_user() { user* new_user = (user*)malloc(sizeof(user)); printf("请输入用户名\n"); scanf("%s", new_user->name); user* current = head; while (current) { if (strcmp(current->name, new_user->name) == 0) { printf("用户名已存在!\n"); free(new_user); return; } current = current->next; } printf("请输入密码:\n"); scanf("%19s", new_user->password); printf("请输入手机号:\n"); scanf("%11s", new_user->phone); new_user->next = head; head = new_user; printf("注册完毕!\n"); } //老用户登录 int loginuser() { char name_temp[20]; char password_temp[20]; char phone_temp[12]; printf("是否为管理员?\n"); int choice = 0; printf("1.是\n2.不是\n"); switch (choice) { case 1: printf("进入管理员界面"); break; case 2: printf("进入用户界面"); break; } printf("用户名:"); scanf("%19s", name_temp); printf("密码:"); scanf("%19s", password_temp); user* current = head; while (current) { if (strcmp(current->name, name_temp) == 0&&strcmp(current->password,password_temp)==0) { return 1; } current = current->next; } return 0; } //保存链表进文件 void save_to_file() { FILE* fp = fopen("user.date", "w"); if (!fp) { printf("数据保存失败!\n"); } user* current = head; while (current) { fprintf(fp, "%s %s %s\n",current->name,current->password,current->phone); current = current->next; } fclose(fp); } //释放内存 void free_list() { user* current = head; while (current) { user* temp = current; current = current->next; free(temp); } head = NULL; } int main() { load_from_file(); int choice = -1; do { printf("\n1.注册\n2.登录\n3.退出\n请选择:"); scanf("%d", &choice); switch (choice) { case 1: register_user(); break; case 2: if (loginuser()) printf("登录成功!\n"); else printf("用户名或者密码错误\n"); break; case 3: printf("正在退出.......\n"); choice = 3; break; default: printf("无效输入!\n"); } } while (choice != 3); save_to_file(); free_list(); return 0; }对管理员部分就行完善
03-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值