C语言 登录系统代码.doc

上传人:韩长文 文档编号:8635593 上传时间:2020-12-08 格式:DOC 页数:4 大小:19.50KB
返回 下载 相关 举报
C语言 登录系统代码.doc_第1页
第1页 / 共4页
C语言 登录系统代码.doc_第2页
第2页 / 共4页
C语言 登录系统代码.doc_第3页
第3页 / 共4页
C语言 登录系统代码.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《C语言 登录系统代码.doc》由会员分享,可在线阅读,更多相关《C语言 登录系统代码.doc(4页珍藏版)》请在三一文库上搜索。

1、.#include #include typedef struct char name100; char pw100;uifo;#define USER_FILE data.bin#define DEFAULT_NAME guest#define DEFAULT_PW 123void write_data(uifo *info) unsigned char len; FILE *fp; fp = fopen(USER_FILE, wb); if(fp = NULL) printf(can not open file n); return; len = strlen(info-name); fw

2、rite(&len, 1, 1, fp); fwrite(info-name, 1, len, fp); len = strlen(info-pw); fwrite(&len, 1, 1, fp); fwrite(info-pw, 1, len, fp); fclose(fp);void read_data(uifo *info) FILE *fp; unsigned char len; fp = fopen(USER_FILE, rb); if(fp = NULL) strcpy(info-name, DEFAULT_NAME); strcpy(info-pw, DEFAULT_PW); w

3、rite_data(info); else memset(info, 0, sizeof *info); fread(&len, 1, 1, fp); fread(info-name, 1, len, fp);精品. fread(&len, 1, 1, fp); fread(info-pw, 1, len, fp); fclose(fp); int main() uifo info; char pw100=0, pw_confirm100=0; int wt = 0; memset(&info, 0, sizeof info); read_data(&info); printf(welcome

4、! please loginn); while(1) printf(please input your user namen); scanf(%s, pw); if(strcmp(pw, info.name) != 0) printf(no such user namen); continue; printf(please input your passwordn); scanf(%s, pw); if(strcmp(pw, info.pw) != 0) printf(password errorn); else break; wt +; if(wt = 3) printf(3 times p

5、assword error, exit!n); return -1; while(1) int i; printf(input 1 to change your passwordninput 0 to exitn); scanf(%d, &i); if(i = 0) break; if(i = 1) 精品. while(1) printf(please input your original passwordn); scanf(%s, pw); if(strcmp(pw, info.pw) != 0) printf(original password is not correctn); con

6、tinue; printf(please input your new passwordn); scanf(%s, pw); printf(please confirm your new passwordn); scanf(%s, pw_confirm); if(strcmp(pw, pw_confirm) != 0) int j; printf(the new passwords are not same in two times input!n); while(1) printf(input 1 to change password againninput 2 to back to last stepninput 0 to exitn); scanf(%d, &j); if(j = 0) return -2; if(j = 1 | j = 2) break; printf(unknown inputn); if(j = 2) break; continue; strcpy(info.pw, pw); write_data(&info); break; else printf(unknown input, should be 0/1n); printf(Bye!n); return 0;如有侵权请联系告知删除,感谢你们的配合!精品

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1