forked from zhangshifen38/store
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17d9f80
commit 4a2a251
Showing
9 changed files
with
204 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef DATA_H | ||
#define DATA_H | ||
|
||
#define MAX 200 | ||
|
||
typedef struct User{ | ||
int adm; //用户标识符 | ||
char name[MAX]; //用户名 | ||
char pwd[17]; //密码 | ||
}USER; | ||
//用户结构体 | ||
|
||
typedef struct User_Node{ | ||
USER user; //用户结构体主体 | ||
struct User_Node *node //结构体指针 | ||
}USER_N; | ||
|
||
typedef struct Goods{ | ||
int type; //商品代码 | ||
char name[MAX]; //商品名称 | ||
int num; //商品进货数量 | ||
double price; //商品价格 | ||
int time; //进货时间 | ||
int sold; //商品销量 | ||
}GOO; | ||
//商品结构体 | ||
|
||
typedef struct Goods_Node{ | ||
GOO goods; //商品结构体主体 | ||
struct Goods_Node *node; //结构体指针 | ||
}GOO_N; | ||
//商品链表结点结构体 | ||
|
||
typedef struct Customer{ | ||
char name[MAX]; //顾客姓名 | ||
int star; //顾客星级 | ||
double cost; //消费额 | ||
}CUS; | ||
//顾客信息结构体 | ||
|
||
typedef struct Customer_Node{ | ||
CUS customer; //顾客结构体主体 | ||
struct Customer_Node *node;//结构体指针 | ||
}CUS_N; | ||
//顾客信息链表结点结构体 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "login.h" | ||
|
||
//登录模块 | ||
int login() | ||
{ | ||
int adm; | ||
|
||
FILE *user; | ||
if(user=fopen(".//users.txt","r")==NULL) | ||
{ | ||
printf("未检测到用户数据!"); | ||
if(user=fopen(".//users.txt","w")==NULL) | ||
{ | ||
printf("创建用户数据失败,请检查!\n"); | ||
} | ||
else | ||
{ | ||
printf("已自动为您初始化用户数据!\n"); | ||
} | ||
} | ||
else | ||
{ | ||
char ch=getc(user); | ||
USER new; | ||
if(ch==EOF) | ||
{ | ||
puts("未检测到已有用户,自动为您创建管理员账户!"); | ||
puts("请设置您的用户名:"); | ||
gets(new.name); | ||
puts("请设置您的密码:(不超过16个字符)"); | ||
int i=0; //计数变量 | ||
do | ||
{ | ||
new.pwd[i]=getch(); | ||
if(new.pwd[i]=='\b') | ||
{ | ||
if(i==0) | ||
{ | ||
continue; | ||
} | ||
i=i-1; | ||
printf("\b"); | ||
} | ||
else | ||
{ | ||
printf("*"); | ||
} | ||
}while(new.pwd[i++]!='\r' && new.pwd[i]!='\n' && i<16); //为什么在windows的cmd下回车符是\r啊T_T | ||
fclose(user); | ||
user=fopen(".//users.txt","w"); | ||
fprintf(user,"1 %s %s\n",new.name,new.pwd); | ||
fclose(user); | ||
} | ||
else | ||
{ | ||
; | ||
} | ||
} | ||
|
||
putchar('\n'); | ||
adm=1; | ||
return adm; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef LOGIN_H | ||
#define LOGIN_H | ||
|
||
#include <stdio.h> | ||
#include <conio.h> | ||
#include <string.h> | ||
#include "data.h" | ||
|
||
int login(); //怬 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters