代码拉取完成,页面将自动刷新
#include<stdio.h>
#include<string.h>
#include<stdbool.h>
#include<stdlib.h>
#include<getch.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/msg.h>
#include"struct.h"
#include"interface.h"
#include"tools.h"
void register_interface(C_to_s* c)
{
system("clear");
printf("***********开户***************\n");
User user = {};
printf("请输入姓名\n");
scanf("%s",c->user.name);
printf("请输入身份证号:\n");
scanf("%s",c->user.ident);
printf("请输入设置密码:\n");
scanf("%s",c->user.pass);
c->user.money = 0;
c->user.lock = 0;
//发送消息
int cgid = msgget(ftok(".",500),0);
msgsnd(cgid,c,sizeof(C_to_s)-sizeof(c->type),0);
//获取消息队列
S_to_c s = {c->user.pid};
int sgid = msgget(ftok(".",520),0);
msgrcv(sgid,&s,sizeof(S_to_c),c->user.pid,0);
printf("%s\n",s.buf);
anyone_key();
}
//销户
void cancel_interface(C_to_s* c)
{
system("clear");
printf("*************销户***************\n");
User user = {};
printf("请输入账号\n");
scanf("%d",&c->user.id);
printf("请输入密码:");
scanf("%s",c->user.pass);
scanf("%*c");
printf("是否确认注销(Y/N):");
c->user.ch = getchar();
int cgid = msgget(ftok(".",500),0);
msgsnd(cgid,c,sizeof(C_to_s)-sizeof(c->type),0);
//获取消息队列
S_to_c s = {c->user.pid};
int sgid = msgget(ftok(".",520),0);
msgrcv(sgid,&s,sizeof(S_to_c),c->user.pid,0);
printf("%s\n",s.buf);
anyone_key();
}
//解锁
void deblock_interface(C_to_s* c)
{
system("clear");
printf("*************解锁界面**************\n");
User user = {};
printf("请输入账号\n");
scanf("%d",&c->user.id);
printf("请输入身份证号:");
scanf("%s",c->user.ident);
int cgid = msgget(ftok(".",500),0);
msgsnd(cgid,c,sizeof(C_to_s)-sizeof(c->type),0);
//获取消息队列
S_to_c s = {c->user.pid};
int sgid = msgget(ftok(".",520),0);
msgrcv(sgid,&s,sizeof(S_to_c),c->user.pid,0);
printf("%s\n",s.buf);
anyone_key();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。