用户日程管理

工作大致流程图

#mermaid-svg-Qod5MxXaY8rTdkqK {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-Qod5MxXaY8rTdkqK .error-icon{fill:#552222;}#mermaid-svg-Qod5MxXaY8rTdkqK .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-Qod5MxXaY8rTdkqK .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-Qod5MxXaY8rTdkqK .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-Qod5MxXaY8rTdkqK .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-Qod5MxXaY8rTdkqK .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-Qod5MxXaY8rTdkqK .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-Qod5MxXaY8rTdkqK .marker{fill:#333333;stroke:#333333;}#mermaid-svg-Qod5MxXaY8rTdkqK .marker.cross{stroke:#333333;}#mermaid-svg-Qod5MxXaY8rTdkqK svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-Qod5MxXaY8rTdkqK .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-Qod5MxXaY8rTdkqK .cluster-label text{fill:#333;}#mermaid-svg-Qod5MxXaY8rTdkqK .cluster-label span{color:#333;}#mermaid-svg-Qod5MxXaY8rTdkqK .label text,#mermaid-svg-Qod5MxXaY8rTdkqK span{fill:#333;color:#333;}#mermaid-svg-Qod5MxXaY8rTdkqK .node rect,#mermaid-svg-Qod5MxXaY8rTdkqK .node circle,#mermaid-svg-Qod5MxXaY8rTdkqK .node ellipse,#mermaid-svg-Qod5MxXaY8rTdkqK .node polygon,#mermaid-svg-Qod5MxXaY8rTdkqK .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-Qod5MxXaY8rTdkqK .node .label{text-align:center;}#mermaid-svg-Qod5MxXaY8rTdkqK .node.clickable{cursor:pointer;}#mermaid-svg-Qod5MxXaY8rTdkqK .arrowheadPath{fill:#333333;}#mermaid-svg-Qod5MxXaY8rTdkqK .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-Qod5MxXaY8rTdkqK .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-Qod5MxXaY8rTdkqK .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-Qod5MxXaY8rTdkqK .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-Qod5MxXaY8rTdkqK .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-Qod5MxXaY8rTdkqK .cluster text{fill:#333;}#mermaid-svg-Qod5MxXaY8rTdkqK .cluster span{color:#333;}#mermaid-svg-Qod5MxXaY8rTdkqK div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-Qod5MxXaY8rTdkqK :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}

y=>新用户
y=>新用户
一直循环
命令行启动用户管理
是否新用户?(y/n)
输入用户名
检查用户名是否与已有用户名重复
重复
提示该用户名已被使用
再次输入
没有重复
输入密码
是否存在已有用户名与输入用户名重复,检查是否输入正确
不存在
用户名错误
再次输入
用户名正确
输入密码
检查用户对应密码是否正确?
不正确
密码正确
日程管理
创建子线程提醒
主线程
菜单选项(1.新增,2.查找,3.修改,4.删除,5.退出)
1.新增
提示当前日期,并提示输入日期
检查当前日期是否符合日期标准,是否在当前时间之后,是否与已有的事件冲突
输入事件
输入优先级
2.查找
列出查找子菜单
1.遍历 2.时间查找 3.事件查找
输出所有事件
输出指定时间事件
输出指定事件
3.修改
修改事件
1.通过事件内容修改时间
4.删除
列出删除子菜单
1.时间删除 2.事件内容删除 3.ID删除
输入时间,提示找到该时间所有事件,然后删除
输入内容,提示找到该内容所有事件,然后删除
找到ID,删除事件
5.退出
主线程退出,保留子线程
子线程
进入alert提醒函数
计算当前时间和任务时间与2020-1-1 00:00:00,的间隔秒数进行比较,判断是否提醒

源文件

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <pthread.h>
#include <unistd.h>
#define LENGTH 100char filename[LENGTH];//用户登录后创建或者访问对应文件夹typedef struct Schedule {int ID;int year;int month;int day;int hour;int minute;int second;char content[LENGTH];char priority[LENGTH];struct Schedule* next;
}Schedule;typedef struct  User{char name[LENGTH];char password[LENGTH];char HASH_Password[LENGTH];//加密后的密码struct Schedule *Schedule;struct User *next;
}User;//初始化用户链表
User* Init(){User *eHead = (User*)malloc(sizeof(User));eHead->next=NULL;if(eHead!=NULL){return eHead;}else{printf("空间分配失败!");exit(1);}
}//从文件读取保存的用户
int Load(User *head,int n){FILE *data;//要读取的文件指针int i=0;//结构体数组移动for (; head->next != NULL; head = head->next);User* test = (User*)malloc(sizeof(User));if((data=fopen("userInfo","r"))==NULL){printf("Can not open file\n");return 0;}while(i<=n){fscanf(data,"%s %s\n ",test->name,test->HASH_Password);head->next=test;i++;}fclose(data);return 0;}//判断新用户是否有重名
int check_New(User *eHead,char *name){int flag=1;eHead=eHead->next;while(eHead!=NULL){if(strcmp(eHead->name,name)==0){flag=0;break;}eHead=eHead->next;}return flag;
}//判断老用户用户名是否正确
int check_name(User *eHead,char *name){int flag=0;eHead=eHead->next;while(eHead!=NULL){if(strcmp(eHead->name,name)==0){flag=1;break;}eHead=eHead->next;}return flag;
}//判断老用户密码是否正确
int check_key(User *eHead,char *name,char *key,char *Hkey){int flag=0;eHead=eHead->next;while(eHead!=NULL){if(strcmp(eHead->name,name)==0){strcpy(Hkey,eHead->HASH_Password);//strcpy(key,test->password);int i=0,len=strlen(Hkey);while (i<len){Hkey[i]=Hkey[i]-i-5;i++;}if (strcmp(key,Hkey)==0){flag=1;break;}}eHead=eHead->next;}return flag;
}//初始化日程链表
Schedule *init(){Schedule *head = (Schedule*)malloc(sizeof(Schedule));head->next=NULL;if(head!=NULL){return head;}else{printf("空间分配失败!");exit(1);}
}//检查输入时间是否正确,是否与已经有的事件时间冲突int check_time(int year, int month, int day,int hour,int min,int sec,Schedule *head)
{int monthDays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };int judg = 0;time_t timep;time(&timep);struct tm *p;p = gmtime(&timep);// 判断如果是闰年,则修改二月的monthDays[1]值为29if ((year % 400 == 0) ||(year % 100 != 0 && year % 4 == 0)){monthDays[1] = 29;}if(year<1900 + p->tm_year||year < 0){printf(" Are you sure the entered year[%d] is correct?\n", year);}else if(year>=(1900 + p->tm_year+1)){judg=1;}else if(year>=1900 + p->tm_year){if(month<1 + p->tm_mon||month < 1 || month > 12) {printf("Are you sure the entered month[%d] is correct?\n", month);}else if(month>=(1 + p->tm_mon+1)){judg=1;}else if(month>=1 + p->tm_mon){if(day < p->tm_mday || day < 1 || day > monthDays[month - 1]){printf("Are you sure the entered day[%d] is correct?\n", day);}else if(day>=p->tm_mday+1){judg=1;}else if( monthDays[month - 1] >= day && day >= p->tm_mday){if(hour < p->tm_hour+8){printf("Are you sure the entered hour[%d] is correct?\n", hour);}else if(hour>= p->tm_hour+9){judg=1;}else if(24>=hour && hour>=(p->tm_hour+8)){if(min<p->tm_min||min>60){printf("Are you sure the entered min[%d] is correct?\n", min);}else if(min>p->tm_min+1){judg=1;}else if(p->tm_min<=min && min<=60){if (p->tm_sec>sec||sec>60){printf("Are you sure the entered sec[%d] is correct?\n", sec);}else{judg=1;}}}}}}//判断日期是否重复head=head->next;while(head!=NULL){if (head->year==year&&head->month==month&&head->day==day&&head->hour==hour&&head->minute==min){printf("There is already a task at the current time!\n");judg=0;break;}else{judg=1;}        head=head->next;}return judg;
}//从文件读取保存的事件
int load(Schedule *head,int n){FILE *data;//要读取的文件指针int i=0;//结构题数组移动for (; head->next != NULL; head = head->next);Schedule* test = (Schedule*)malloc(sizeof(Schedule));if((data=fopen(filename,"a+"))==NULL){printf("Can not open file\n");return 0;}while(i<=n){fscanf(data,"%d %d %d  %d %d %d  %s %s\n ",&test->year,&test->month, &test->day,&test->hour, &test->minute, &test->second,test->content,test->priority);head->next=test;i++;}fclose(data);return 0;}//输入新的事件 总是从尾端插入
void insert(Schedule* eHead,Schedule *head) {int x=0;time_t timep;time(&timep);struct tm *p;p = gmtime(&timep);for (; eHead->next != NULL; eHead = eHead->next);Schedule* test = (Schedule*)malloc(sizeof(Schedule));test->next = NULL;do{printf("请输入日期和时间:yyyy-mm-dd hh:mm:ss(例如:2022-7-7 00:00:00)\n");printf("当前时间是:");printf("%d-%02d-%02d %02d:%02d:%02d\n", 1900 + p->tm_year, 1 + p->tm_mon, p->tm_mday, p->tm_hour+8, p->tm_min, p->tm_sec);scanf("%d %*c %d %*c %d %d %*c %d %*c %d", &test->year, &test->month, &test->day,&test->hour, &test->minute, &test->second);x=check_time(test->year,test->month, test->day,test->hour, test->minute, test->second,head);}while(x==0);if(x)printf("Correct!\n");char c_tmp;while ((c_tmp = getchar() != '\n') && c_tmp != EOF);printf("请输入事件内容(最长为50个字符):\n");scanf("%s", test->content);while ((c_tmp = getchar() != '\n') && c_tmp != EOF);printf("请输入事件优先级(高级、中级、低级):\n");scanf("%s", test->priority);while ((c_tmp = getchar() != '\n') && c_tmp != EOF);FILE *fp;fp=fopen(filename, "a+");    //打开文件,储存粗略信息,单纯存储记录fprintf(fp, " %04d %02d %02d  %02d %02d %02d  %s %s \n ",test->year,test->month, test->day,test->hour, test->minute, test->second,test->content,test->priority);fclose(fp);printf("事件已成功保存!\n");eHead->next = test;
}//保存文件内容
void save(Schedule *head){FILE *fp;fp=fopen(filename, "w");  head=head->next;while(head!=NULL){fprintf(fp, " %04d %02d %02d  %02d %02d %02d  %s %s \n ",head->year,head->month, head->day,head->hour, head->minute, head->second,head->content,head->priority);head=head->next;}fclose(fp);
} //比较两事件的时间先后
int compare(Schedule *a,Schedule *b){//将Int格式化为str,直接比较字符串的大小char str_a[100]={0};sprintf(str_a,"%d04%02d%02d%02d%02d%02d",a->year,a->month,a->day,a->hour,a->minute,a->second);char str_b[100]={0};sprintf(str_b,"%d04%02d%02d%02d%02d%02d",b->year,b->month,b->day,b->hour,b->minute,b->second);int n=strcmp(str_a,str_b);if(n>0){return 1;}else{return 0;}
}//排序
Schedule* sort(Schedule *L){Schedule *p, *q, *next;int temp;p = L->next;for( ; p != NULL; p = p->next )    /*每次循环都找出一个最小值,将最小值交换到第一位,然后将指针向后移动一位*/{next = p;for( q = p->next; q; q = q->next )    /*由前向后遍历,找出最小的节点*/{if( compare(next,q)==1 )next = q;}if( next != p ){temp = p->year;p->year = next->year;next->year = temp;temp = p->month;p->month = next->month;next->month = temp;temp = p->day;p->day = next->day;next->day = temp;temp = p->hour;p->hour = next->hour;next->hour = temp;temp = p->minute;p->minute = next->minute;next->minute = temp;temp = p->second;p->second = next->second;next->second = temp;char tem[LENGTH];memcpy(tem,p->content,100);memcpy(p->content,next->content,100);memcpy(next->content,tem,100);}}return L;
}//分配ID
void Assign_ID(Schedule *head){int temp=1;for (head = head->next; head != NULL; head = head->next) {head->ID=temp;temp++;}
}//通过事件ID删除任务
void deleteByID(Schedule *head){Schedule *before,*cur;int temp;printf("请输入事件ID:\n");scanf("%d",&temp);for(before=head,cur=head->next;cur!=NULL;before=before->next,cur=cur->next){if(cur->ID==temp){before->next=cur->next;printf("删除成功\n");break;}}if(cur==NULL){printf("未找到该事件\n");}
}//通过日期删除事件
void deleteByDate(Schedule *head){Schedule *before,*cur;int year;int month;int day;int hour;int minute;int second;printf("请输入日期:yyyy/mm/dd(例如:2018/01/09)\n");scanf("%d %*c %d %*c %d",&year,&month,&day);printf("请输入具体时间:hh:MM:ss(例如:23:01:00)\n");scanf("%d %*c %d %*c %d",&hour,&minute,&second);for(before=head,cur=head->next;cur!=NULL;cur=cur->next,before=before->next){if(cur->day==day && cur->hour==hour && cur->minute==minute && cur->month==month && cur->second==second && cur->year==year){before->next=cur->next;printf("删除成功\n");break;}}if(cur==NULL){printf("未找到该事件\n");}}//通过事件内容删除事件
void deleteByContent(Schedule *head){Schedule *before,*cur;char temp[LENGTH];printf("请输入事件内容:\n");scanf("%s",temp);for(before=head,cur=head->next;cur!=NULL;before=before->next,cur=cur->next){if(strcmp(temp,cur->content)==0){before->next=cur->next;printf("删除成功\n");break;}}if(cur==NULL){printf("未找到该事件\n");}
}//打印事件具体时间
void printInfo(Schedule *Sch){printf("ID: %03d 日期: %04d/%02d/%02d 时间: %02d:%02d:%02d 事件:%s 优先级:%s\n",Sch->ID,Sch->year,Sch->month,Sch->day,Sch->hour,Sch->minute,Sch->second,Sch->content,Sch->priority);
}//修改事件时间
void modifyDate(Schedule *head){char temp[LENGTH];printf("请输入您要查找事件内容:\n");scanf("%s",temp);printf("查找中...");for(head=head->next;head!=NULL;head=head->next){if(head==NULL){printf("未找到该事件\n");return;}if(strcmp(temp,head->content)==0){printf("已找到:\n");printInfo(head);int year;int month;int day;int hour;int minute;int second;printf("进行修改:");printf("请输入日期:yyyy/mm/dd(例如:2018/01/09)\n");scanf("%d %*c %d %*c %d",&year,&month,&day);printf("请输入具体时间:hh:MM:ss(例如:23:01:00)\n");scanf("%d %*c %d %*c %d",&hour,&minute,&second);head->year=year;head->month=month;head->day=day;head->hour=hour;head->minute=minute;head->second=second;}}printf("修改完成\n");}//遍历链表
void travel(Schedule *head){head=head->next;while(head!=NULL){printInfo(head);head=head->next;}
}// 通过具体日期查找事件
void findByDate(Schedule *head){int year;int month;int day;int hour;int minute;int second;printf("请输入日期:yyyy/mm/dd(例如:2018/01/09)\n");scanf("%d %*c %d %*c %d",&year,&month,&day);printf("请输入具体时间:hh:MM:ss(例如:23:01:00)\n");scanf("%d %*c %d %*c %d",&hour,&minute,&second);printf("查找中...");for(head=head->next;head!=NULL;head=head->next){if(head->day==day && head->hour==hour && head->minute==minute && head->month==month && head->second==second && head->year==year){printf("已找到:\n");printInfo(head);break;}}if(head==NULL){printf("未找到该事件\n");}
}//通过事件内容查找事件
void findByScheduleContent(Schedule *head){char temp[LENGTH];printf("请输入您要查找事件内容:\n");scanf("%s",temp);printf("查找中...");for(head=head->next;head!=NULL;head=head->next){if(strcmp(temp,head->content)==0){printf("已找到:\n");printInfo(head);break;}}if(head==NULL){printf("未找到该事件\n");}
}//查找的子菜单,分为 1 遍历 2时间查找 3 事件查找
void find(Schedule *head){char decide = 'y';                          //定义while变量,函数是否继续进行int num;                                  //定义switch变量,函数跳转到哪个子函数while (decide != 'n'){printf("  ***************************************************\n");printf("  ****  1  遍历  2 时间查找   3 事件查找  4 退出 ****\n");printf("  ***************************************************\n");scanf("%d", &num);fflush(stdin);switch (num){case 1:travel(head);break;case 2:findByDate(head);break;case 3:findByScheduleContent(head);break;default:decide = 'n';break;}}
}//删除事件的子菜单,分为 1 时间查找删除 2事件查找删除 3 ID查找删除
void ScheduleDelete(Schedule *head){char decide = 'y';                          //定义while变量,函数是否继续进行int num;                                  //定义switch变量,函数跳转到哪个子函数while (decide != 'n'){printf("  ***************************************************\n");printf("  ****     1 时间删除   2 事件删除  3 ID删除  4 退出     ****\n");printf("  ***************************************************\n");scanf("%d", &num);fflush(stdin);switch (num){case 1:deleteByDate(head);break;case 2:deleteByContent(head);break;case 3:deleteByID(head);break;default:decide = 'n';break;}}
}// 获得2022-1-1 00:00:00到当前时间(忽略秒,只计算到分)的秒数
long long int difpsec(){int monthDays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };int judg = 0;time_t t;struct tm* llt;time(&t);//获取Unix时间戳。llt = localtime(&t);//转为时间结构。int flag = 0,sumday=0,year,md,difyear;int pyear = llt->tm_year + 1900 - 2022;int pmon = llt->tm_mon + 1-1;int pday = llt->tm_mday-1;int phour = llt->tm_hour;int pmin = llt->tm_min;for (difyear = 0; difyear <= pyear; difyear++) {if (difyear == 0) {//此时在计算当前年的天数// 判断如果是闰年,则修改二月的monthDays[1]值为29if (((llt->tm_year+1900) % 400 == 0) || ((llt->tm_year + 1900) % 100 != 0 && (llt->tm_year + 1900) % 4 == 0)){monthDays[1] = 29;}for (md = 0; md <= pmon; md++) {sumday = sumday + monthDays[md];}sumday = sumday + pday;}else if (difyear >= 1) {//此时在计算以前年的天数year = llt->tm_year + 1900 - difyear;// 判断如果是闰年,天数加366,否则加365if ((year % 400 == 0) || (year % 100 != 0 && year % 4 == 0)){sumday = sumday + 366;}else {sumday = sumday + 365;}}}long long int sec = 0;sec = ((sumday * 24 + phour) * 60 + pmin) * 60+llt->tm_sec;return sec;
}// 提醒有无即将需要完成的事件
void *alert(void *arg) {while(1){Schedule *Head;                                //定义链表的头指针Head = init();                              //给头指针开辟空间Head->next = NULL;                          //初始化头指针FILE *fp;int Flag = 0, count = 0;if((fp = fopen(filename, "a+")) == NULL){printf("Can not open file\n");}while(!feof(fp)){Flag = fgetc(fp);if(Flag == '\n'){count++;}}fclose(fp);for (int i = 0; i < count; i++){load(Head,i);}Head=sort(Head);Assign_ID(Head);time_t t;struct tm* p;time(&t);//获取Unix时间戳。p = localtime(&t);//转为时间结构。int flag=0;long long int sec = 0,psec=0;int monthDays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };Head=Head->next;while(Head != NULL){int sumday=0,year=0,md=0,difyear=0;int pyear = Head->year - 2022;int pmon = Head->month -1;int pday = Head->day-1;int phour = Head->hour;int pmin = Head->minute;psec=difpsec();//当前时间距离2022-1-1 00:00:00的秒数for (difyear = 0; difyear <= pyear; difyear++) {if (difyear == 0) {//此时在计算链表储存年份的天数// 判断如果是闰年,则修改二月的monthDays[1]值为29if ((Head->year % 400 == 0) || (Head->year % 100 != 0 && Head->year % 4 == 0)){monthDays[1] = 29;}for (md = 0; md <= pmon; md++) {sumday = sumday + monthDays[md];}sumday = sumday + pday;}else if (difyear >= 1) {//此时在计算链表储存年份以前年的天数year = Head->year - difyear;// 判断如果是闰年,天数加366,否则加365if ((year % 400 == 0) || (year % 100 != 0 && year % 4 == 0)){sumday = sumday + 366;}else {sumday = sumday + 365;}}}sec = ((sumday * 24 + phour) * 60 + pmin) * 60+Head->second;//任务距离2022-1-1 00:00:00的秒数if (flag==0 && (sec-psec)<=1800 && (sec-psec)>=0) {printf("\n\n  ****************************************************\n");printf("*************    你有如下事件将要完成:     *************\n");printf("*****   日期: %04d/%02d/%02d 时间: %02d:%02d:%02d 事件:%s    *****\n ",Head->year, Head->month, Head->day, Head->hour,Head->minute, Head->second, Head->content);printf("  ****************************************************\n");flag = 1;}while (flag==1 && difpsec()<=sec){}Head = Head->next;}while (flag==0){sleep(60);break;}}
}//菜单列表
void menu(){pthread_t th2;char decide = 'y';                          //定义while变量,函数是否继续进行int num = 0;                                //定义switch变量,函数跳转到哪个子函数Schedule *head;                                //定义链表的头指针head = init();                              //给头指针开辟空间head->next = NULL;                          //初始化头指针FILE *fp;int flag = 0, count = 0;if((fp = fopen(filename, "a+")) == NULL){printf("Can not open file\n");}while(!feof(fp)){flag = fgetc(fp);if(flag == '\n'){count++;}}fclose(fp);for (int i = 0; i < count; i++){load(head,i);}head=sort(head);Assign_ID(head);pthread_create(&th2,NULL,alert,NULL);while (decide != 'n'){printf("  ****************************************************\n");printf("  **********           日程管理系统           ********\n");printf("  ****************************************************\n");printf("  **********     1 输入  2 查找  3 修改       ********\n");printf("  **********         4 删除  5 退出           ********\n");printf("  ****************************************************\n");sleep(3);scanf("%d", &num);switch (num){case 1:insert(head,head);head=sort(head);Assign_ID(head);break;case 2:find(head);break;case 3:modifyDate(head);save(head);break;case 4:ScheduleDelete(head);head=sort(head);Assign_ID(head);save(head);break;default:decide = 'n';break;}}pthread_detach(th2);
}//输入新的用户 总是从尾端插入
void Insert(User* eHead,User *head) {for (; eHead->next != NULL; eHead = eHead->next);User* test = (User*)malloc(sizeof(User));test->next = NULL;int judg=0;char choice[1];extern char filename[LENGTH];printf("是新用户么?(输入Y/N,不区分大小写)\n");scanf("%s",choice);if (strcmp("Y",choice)==0||strcmp(choice,"y")==0){while(judg==0){printf("请输入用户名:\n");scanf("%s",test->name);judg=check_New(head,test->name);if (judg==1){strcpy(filename,test->name);break;}printf("当前用户名已被使用,请重新输入\n");}char c_tmp;while ((c_tmp = getchar() != '\n') && c_tmp != EOF);if(judg){printf("请输入密码:\n");char key[LENGTH]={'\0'};scanf("%s",key);printf("%s",key);strcpy(test->password,key);//strcpy(key,test->password);int i=0,len=strlen(key);while (i<len){key[i]=key[i]+i+5;i++;}strcpy(test->HASH_Password,key);}FILE *fp;fp=fopen("userInfo", "a+");    //打开文件,储存粗略信息,单纯存储记录  fprintf(fp,"%s %s\n",test->name,test->HASH_Password);fclose(fp);printf("用户已成功注册!\n");menu();}else if(strcmp("N",choice)==0||strcmp(choice,"n")==0){printf("请输入用户名:\n");while(judg==0){scanf("%s",test->name);judg=check_name(head,test->name);if(judg==1){strcpy(filename,test->name);break;}printf("用户名不正确,请重新输入:\n");}judg=0;char c_tmp;while ((c_tmp = getchar() != '\n') && c_tmp != EOF);printf("请输入密码:\n");while(judg==0){char KEY[LENGTH];scanf("%s",KEY);judg=check_key(head,test->name,KEY,test->HASH_Password);printf("%d\n",judg);if(judg==1){break;}printf("用户密码不正确,请重新输入:\n");}if(judg==1){printf("用户成功登录!\n");menu();}}eHead->next = test;
}int main()
{   time_t timep;time(&timep);struct tm *p;p = gmtime(&timep);printf("当前时间是:");printf("%d-%02d-%02d %02d:%02d:%02d\n", 1900 + p->tm_year, 1 + p->tm_mon, p->tm_mday, p->tm_hour+8, p->tm_min, p->tm_sec);//pthread_t th1;//pthread_create(&th1,NULL,main,NULL);char Decide = 'y';                          //定义while变量,函数是否继续进行User *eHead;                                //定义链表的头指针eHead = Init();                              //给头指针开辟空间eHead->next = NULL;                          //初始化头指针FILE *fp;int flag = 0, count = 0;if((fp = fopen("userInfo", "a+")) == NULL){printf("Can not open file\n");}while(!feof(fp)){flag = fgetc(fp);if(flag == '\n')count++;}fclose(fp);for (int i = 0; i < count; i++){Load(eHead,i);}while (Decide != 'n'){printf("\n\n");printf("\t*******************************\n");printf("\t********* 用户登录     *********\n");printf("\t*******************************\n");printf("\n\n");Insert(eHead,eHead);return 0;}
}

Cmake文件

cmake_minimum_required(VERSION 3.10.2)# set the project name
project(Schedule_Management)set(CMAKE_BUILD_TYPE "Debug")# add the executable
add_executable(Schedule_Management Schedule.cc)set(CMAKE_CXX_FLAGS -lunistd)
set(CMAKE_CXX_FLAGS -pthread)
message(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")

简单日程管理系统,包含用户管理以及多线程定时提醒等功能相关推荐

  1. 一步一步使用Ext JS MVC与Asp.Net MVC 3开发简单的CMS后台管理系统之用户管理(1)...

    应用程序的基本框架已经搭建好了,现在要做的是完成一个个的功能模块.先从简单做起,完成用户管理模块,该模块主要功能是使用一个Grid显示用户信息,并使用RowEditing进行用户的编辑.添加操作.Gr ...

  2. web实践小项目一:简单日程管理系统(涉及html/css,javascript,python,sql,日期处理)...

    暑假自学了些html/css,javascript和python,苦于学完无处练手几乎过目即忘...最后在同学的建议下做了个简单日程管理系统.借第一版完成之际,希望能将实践期间犯过的错误和获得的新知进 ...

  3. 权限管理系统之用户管理

    4.1 用户管理 用户是登录系统的楔子. 用户管理主要是针对平台的使用者进行管理.包括: ① 用户信息(帐号.密码.姓名等个人基本信息和状态.职位.职务等平台信息) ② 用户组设置.组织归属 ③ 角色 ...

  4. 【学生管理系统】用户管理之用户登录

    目录 2. 用户管理 2.1 环境搭建 2.1.1 前端环境 2.1.2 后端环境(9000) 2.2 用户登录 2.2.1 需求 2.2.2 后端实现 2.2.3 前端实现 2.3 首页 2.3.1 ...

  5. 制作CRM管理系统03(用户管理)

    目录 一.用户管理界面显示用户信息 1.1.前端HTML 1.1.1.通过axios发送请求到Servlet获取用户列表数据 1.1.2.将Servlet响应的数据通过v-for指令显示到table上 ...

  6. 服务器多账户管理系统,统一用户管理解决方案

    一.方案概述 日常工作中,使用人员在使用各应用系统时都要做登录操作,需要记住每个系统的登录口令:对于系统管理员,人员的新增.调离或退休都需要到各个系统中都要进行重新配置.若操行不及时或遗漏,就会带来系 ...

  7. 若依权限管理系统(用户管理)

    一.用户管理 权限管理子系统中最直接的权限控制对象是用户,我们要控制用户对资源的访问权限 核心业务分析 这里的用户为系统管理员添加的用户,是系统管理员,管理员在添加这个账户,会为账户设置一些基础信息, ...

  8. aws cognito_AWS Cognito的用户管理—(2/3)核心功能

    aws cognito by Kangze Huang 黄康泽 AWS Cognito的用户管理-(2/3)核心功能 (User Management with AWS Cognito - (2/3) ...

  9. mysql 用户管理系统_mysql 用户管理

    MySQL账户管理 在我们之前登录MySQL的时候我们都是直接使用的root用户,root用户属于数据库系统中的超级管理员,有权限对mysql进行任何想要做的操作. 如果在生产环境下操作数据库时也是全 ...

最新文章

  1. 大数据软件产品研发进展及挑战
  2. 计算机科学中抽象的好处与问题—伪共享等实例分析
  3. 服务器文件数量监控,服务器监控指标有哪些?好文章一定要收藏
  4. 爬虫python能做什么外国人-利用爬虫技术能做到哪些很酷很有趣很有用的事情?...
  5. python 学习笔记 5 -- 文件输入输出
  6. 面试笔记——C++11新特性
  7. [云炬创业基础笔记]第七章创业资源测试6
  8. boost::graph::distributed::distributed_queue用法的测试程序
  9. mysql的所有权限
  10. 小师妹学JVM之:JDK14中JVM的性能优化
  11. 痞子衡嵌入式:第一本Git命令教程(0)- 索引
  12. python json.loads json.dumps(ensure_ascii = False) 汉字乱码问题解决
  13. 古登堡是垂直搜索引擎吗_网站排名,提高内容输出频率,就一定要对排名好吗?-SEO...
  14. 下面对html描述正确的有多选题,YS - 《网页制作》复习题(多选题)
  15. 【基础教程】信噪比+香农公式【1748期】
  16. linux运维工程师做些什么-肤浅篇
  17. 怎么设置百度网盘免验证登陆?
  18. 1、背景属性 背景颜色绘制区域——background-clip属性
  19. Origin——全局垂直光标
  20. 还要帮彬彬做课件,我苦啊

热门文章

  1. 淘宝店铺买家订单+淘宝店铺买家订单物流获取步骤说明
  2. 第十三章、IO流_File类与递归/基本流/增强流/属性集与打印流__黑马Java第57期个人学习笔记_个人笔记
  3. c语言中箭头的作用,为什么C中的箭头(-)运算符存在?
  4. FatFs文件系统移植过程及中度分析
  5. 室内主动导航系统在高铁站场景应用分析
  6. iframe 边框去除,使用大全
  7. 贝叶斯课后习题(零)常用分布
  8. H5实现扫码读取二维码条形码功能(二维码+条形码)
  9. Vue图片在为动态变量路径显示不出来怎么办 ,但是通过img标签显示正常 这是为什么?
  10. 敷完面膜后要擦水乳吗_敷完面膜还要擦水乳吗