电商系统之超管-管理员-商品(C语言)

2023-11-10 21:10

本文主要是介绍电商系统之超管-管理员-商品(C语言),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

大一暑假实训项目,主要对文件内容的增删改查,链表的基本应用。

编程小白,会的不多,只写了一些基本功能,函数大多是不带返回值的,避免错乱,简洁一些。

不过代码的健壮性还是不错滴。

代补功能:找回密码,各种信息独立修改。闲麻烦就没有打了OAO。

展示部分代码,如有错漏还望指正。


目录

文件存储格式

管理员 Administrator

超级管理员 SuperAdministrator

商品 MobilePhone

用户 Registering 

代码

提示注释和头文件及宏定义

结构体

函数原型

主函数

初始化超级管理员密码

超级管理员入口

管理员入口

注册管理员

注销管理员

修改管理员密码

查询用户

修改超级管理员密码

商品相关函数菜单

展示所有商品

添加商品

删除商品

修改商品价格

添加商品折扣

假二维码


文件存储格式

管理员 Administrator

依次:账号>密码>姓名>性别>电话号码


超级管理员 SuperAdministrator

依次:账号>密码,只有一个超级管理员。

 


商品 MobilePhone

依次:编号>品牌>价格>折扣>型号

 


用户 Registering 

依次:账号>密码>姓名>性别>电话号码>余额


代码

提示注释和头文件及宏定义

// fflush(stdin);
// 清空输入缓冲区// while((ch = getchar()) != '\n' && ch != EOF);
// 逐个读字符,遇到回车或者文本结尾为止
// 用于清空缓冲区// strspn(char * str_1, char * str_2)
// str_1 中的字符在 str_2 中, 则加 1
// 遇到第一个不在 str_2 中的字符, 则停止比较#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>  //便于生成随机数
#define SIZE 8    //定义数组大小
#define ch_1 "龖"  //用于生成仿二维码
#define ch_2 "  "  //二维码空白处
#define str "0123456789abcdefghijklmnopqrstuvwxyz"  //字母和数字

结构体

typedef struct superAdministrator  //超级管理员的结构体
{int account;  //超级管理员的账户 	int 6位数char password[SIZE*2];  //超级管理员的密码    int 9-15位数}SuperAdministrator;typedef struct administrtor  //管理员的结构体
{int account;  //管理员账号  6位char password[SIZE*2];  //密码  9-15位char name[SIZE];  //姓名char gender[SIZE];  //性别char telNum[SIZE*2];  //电话号码  11位struct administrtor * next;}Administrator;typedef struct mobile_phone  //手机的结构体
{int ID;  //编号  6位char type[SIZE];  //品牌  8位以内int price;  //价格double discount;  //折扣char name[SIZE*2];  //型号 小于16位struct mobile_phone * next;}MobilePhone;typedef struct customer  //顾客的结构体
{int account;  //顾客账号  6位char password[SIZE*2];  //密码  9-15位char name[SIZE];  //姓名char gender[SIZE];  //性别char telNum[SIZE*2];  //电话号码  11位int balance;  //用户余额struct customer * next;}customer;

函数原型

一共21个。

void Initial_super_administrator();  //初始化超级管理员
void loginSuperAdmin();  //超级管理员入口
void loginAdmin();  //管理员入口
void loginUser();  //用户入口
void createAdministrator();  //注册管理员
void removeAdministrator();  //注销管理员
void reviseAdministratorPassword();  //修改管理员密码
void SearrchCt();  //查询顾客
void changeSuAdminPassword();  //修改超级管理员密码
void relevant_Product();  //商品相关函数
void showInfo();  //展示所有商品信息
void addProduct();  //添加商品
void deleteProduct();  //删除商品
void reviseProduct();  //修改商品信息
void merchandiseDiscount();   //商品折扣
void input_error();  //输入错误显示
void file_open_error(FILE * fp);  //文件打开失败
void malloc_defeat(Administrator * A);  //动态内存申请失败
void admi_Destrong_List(Administrator * L);  //摧毁链表管理员
void prod_Destrong_List(MobilePhone * L);  //摧毁链表商品
void Payment_QR_code();  //支付二维码

主函数

int main()  //主函数
{Initial_super_administrator();  //初始化超级管理员while(1){char sel;  //选择char ch;  //用于清空缓冲区printf("||------------------------------------------||\n");printf("||     Welcome to Phone product system.     ||\n");printf("||------------------------------------------||\n");printf("||          【1】超级管理员登录             ||\n");printf("||          【2】管理员登录                 ||\n");printf("||          【0】退出                       ||\n");printf("||------------------------------------------||\n");printf("||   请选择: ");while((sel = getchar()) == '\n');  //不管输入什么都只读取第一个字符(除换行)while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区(清空第一个字符后的每一个字符)system("cls");  //清屏switch(sel){case '1':loginSuperAdmin();  //超级管理员入口break;case '2':loginAdmin();  //管理员入口break;case '0':printf("||------------------------------------------||\n");printf("||            系  统  已  关  闭            ||\n");printf("||------------------------------------------||\n");exit(0);default:input_error();  //输入错误显示}}return 0;
}

 


 

初始化超级管理员密码

主要是怕在某次测试中把密码忘了,每次都初始化,方便一些。不要也没关系。

void Initial_super_administrator()  //每次打开程序都会重新初始化超级管理员账号密码
{FILE * fp;const int account = 123456;  //常量避免值被修改const int password = 123456789;fp = fopen("SuperAdministrator.txt", "w");  //只写,无文件就创建文件file_open_error(fp);  //文件是否打开失败fprintf(fp, "%d\t%d\t", account, password);fclose(fp);  //关闭文件
}

超级管理员入口

void loginSuperAdmin()  //超级管理员入口
{char ch, sel;SuperAdministrator sa_1;  //超级管理员账号FILE * fp;  //文件指针int account;  //记录账号char password[SIZE*2];  //记录密码int len_1, len_2;  //记录密码个数, 记录密码合法字符个数while(1){while(1){printf("||------------------------------------------||\n");printf("||    输入 0 可取消登录, 请输入 6 位数字    ||\n");printf("||------------------------------------------||\n");printf("||  超级管理员账号:");scanf("%d", &account);system("cls");  //清屏if(account == 0)  //输入 0 返回上一级{return;}if(account<=100000 || account>999999)  //不是六位的数字{while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||      账号格式错误, 请输入 6 位数字       ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;  //账号格式正确}}while(1){printf("||------------------------------------------||\n");printf("||   输入 0 可取消登录, 9-15 位字母或数字   ||\n");printf("||------------------------------------------||\n");printf("||  超级管理员密码:");scanf("%s", password);system("cls");  //清屏if(strcmp(password, "0") == 0){return;}len_1 = strlen(password);len_2 = strspn(password, str);if(len_1<9 || len_1>15 || len_2<9 || len_2>15){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||     密码格式错误, 9-15 位字母或数字      ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}fp = fopen("SuperAdministrator.txt", "r");  //只读,避免修改file_open_error(fp);  //文件是否打开失败fscanf(fp, "%d\t%s\t", &sa_1.account, sa_1.password);if(account != sa_1.account || strcmp(password, sa_1.password) != 0)  //账号或密码错误{printf("||------------------------------------------||\n");printf("||       账号或密码错误, 请重新输入         ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);continue;}printf("||------------------------------------------||\n");printf("||              登  陆  成  功              ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏while(1){printf("||------------------------------------------||\n");printf("||        超  级  管  理  员  菜  单        ||\n");printf("||------------------------------------------||\n");printf("||          【1】注册管理员                 ||\n");printf("||          【2】注销管理员                 ||\n");printf("||          【3】修改管理员密码             ||\n");printf("||          【4】查询顾客                   ||\n");printf("||          【5】修改密码                   ||\n");printf("||          【6】商品相关菜单               ||\n");printf("||          【0】退出登录                   ||\n");printf("||------------------------------------------||\n");printf("||   请选择: ");while((sel = getchar()) == '\n');  //不管输入什么都只读取第一个字符(除换行)while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区(清空第一个字符后的每一个字符)system("cls");  //清屏switch(sel){case '1':createAdministrator();  //添加管理员break;case '2':removeAdministrator();  //删除管理员break;case '3':reviseAdministratorPassword();  //修改管理员密码break;case '4':SearrchCt();  //查询顾客break;case '5':changeSuAdminPassword();  //修改超级管理员密码return;case '6':relevant_Product();  //商品相关函数break;case '0':fclose(fp);  //关闭文件return;  //返回上一级default:input_error();  //输入错误显示}}}
}

 


 

管理员入口

void loginAdmin()  //管理员入口
{char ch, sel;int flag = 0;  //记录是否查找成功Administrator a_1;  //管理员账号 a_1FILE * fp;  //文件指针int account;char password[SIZE*2];  //存储输入的账号密码int len_1, len_2;  //记录密码个数, 记录密码合法字符个数while(1){while(1){printf("||------------------------------------------||\n");printf("||    输入 0 可取消登录, 请输入 6 位数字    ||\n");printf("||------------------------------------------||\n");printf("||  管理员账号:");scanf("%d", &account);system("cls");  //清屏if(account == 0)  //输入 0 返回上一级{return;}if(account<=100000 || account>999999)  //不是六位的数字{while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||      账号格式错误, 请输入 6 位数字       ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;  //账号格式正确}}while(1){printf("||------------------------------------------||\n");printf("||   输入 0 可取消登录, 9-15 位字母或数字   ||\n");printf("||------------------------------------------||\n");printf("||  管理员密码:");scanf("%s", password);system("cls");  //清屏if(strcmp(password, "0") == 0){return;}len_1 = strlen(password);len_2 = strspn(password, str);if(len_1<9 || len_1>15 || len_2<9 || len_2>15){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||     密码格式错误, 9-15 位字母或数字      ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}fp = fopen("Administrator.txt", "r");  //打开文件file_open_error(fp);  //文件是否打开失败while(!feof(fp))  //文件指针到达末尾则返回 1{fscanf(fp, "%d\t%s\t%s\t%s\t%s\t\n", &a_1.account, a_1.password, a_1.name, a_1.gender, a_1.telNum);if(account == a_1.account && strcmp(password, a_1.password) == 0)  //账号密码都相同{flag = 1;  //登录成功break;}}if(flag == 0){printf("||------------------------------------------||\n");printf("||       账号或密码错误, 请重新输入         ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);  //关闭文件continue;}printf("||------------------------------------------||\n");printf("||              登  陆  成  功              ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏while(1){printf("||------------------------------------------||\n");printf("||            管  理  员  菜  单            ||\n");printf("||------------------------------------------||\n");printf("||          【1】展示所有商品信息           ||\n");printf("||          【2】添加商品                   ||\n");printf("||          【3】删除商品                   ||\n");printf("||          【4】修改商品价格               ||\n");printf("||          【5】添加商品折扣               ||\n");printf("||          【6】查询顾客                   ||\n");printf("||          【0】退出登录                   ||\n");printf("||------------------------------------------||\n");printf("||   请选择: ");while((sel = getchar()) == '\n');  //不管输入什么都只读取第一个字符(除换行)while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区(清空第一个字符后的每一个字符)system("cls");  //清屏switch(sel){case '1':showInfo();  //展示所有商品信息system("pause");system("cls");break;case '2':addProduct();  //添加商品break;case '3':deleteProduct();  //删除商品break;case '4':reviseProduct();  //修改商品价格break;case '5':merchandiseDiscount();  //添加商品折扣break;case '6':SearrchCt();  //查询顾客break;case '0':fclose(fp);  //关闭文件return;  //返回上一级default:input_error();  //输入错误显示}}}
}

 


 

注册管理员

每次注册管理员,实际就是在文件末尾追加一个,账号用随机时生成,所以说,可能会出现账号相同的情况。

void createAdministrator()  //注册管理员
{srand((unsigned)time(NULL));  //种子库,成逐渐增大或逐渐减小char ch;Administrator a_1;  //管理员 a_1FILE * fp;int len_1, len_2;  //记录密码个数, 记录密码合法字符个数while(1){printf("||------------------------------------------||\n");printf("||     输入 0 可退出注册, 8 位以内字母      ||\n");printf("||------------------------------------------||\n");printf("||  管理员姓名: ");scanf("%s", a_1.name);system("cls");  //清屏if(strcmp(a_1.name, "0") == 0)  // 0 退出注册{return;}len_1 = strlen(a_1.name);if(len_1 < 8){break;}else{while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||       姓名格式不正确, 8 位以内字母       ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏}}while(1){printf("||------------------------------------------||\n");printf("||   输入 0 可退出注册, 请输入 11 位数字    ||\n");printf("||------------------------------------------||\n");printf("||  管理员手机号码: ");scanf("%s", a_1.telNum);system("cls");  //清屏if(strcmp(a_1.telNum, "0") == 0)  // 0 退出注册{return;}if(strspn(a_1.telNum, "0123456789") == 11){break;}else{while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||   手机号码格式不正确, 请输入 11 位数字   ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏}}while(1){printf("||------------------------------------------||\n");printf("||       输入 0 可退出注册, 男 或 女        ||\n");printf("||------------------------------------------||\n");printf("||  管理员性别: ");scanf("%s", a_1.gender);system("cls");  //清屏if(strcmp(a_1.gender, "0") == 0)  // 0 退出注册{return;}if(strcmp(a_1.gender, "男") == 0 || strcmp(a_1.gender, "女") == 0){break;}else{while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||      性别格式不正确, 请输入 男 或 女     ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏}}while(1){printf("||------------------------------------------||\n");printf("||   输入 0 可退出注册, 9-15 位字母或数字   ||\n");printf("||------------------------------------------||\n");printf("||   管理员密码:  ");scanf("%s", a_1.password);system("cls");  //清屏if(strcmp(a_1.password, "0") == 0){return;}len_1 = strlen(a_1.password);len_2 = strspn(a_1.password, str);if(len_1<9 || len_1>15 || len_2<9 || len_2>15){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||     密码格式错误, 9-15 位字母或数字      ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}a_1.account = 100000 + rand()%900000;fp = fopen("Administrator.txt", "a");  //只写,在末尾添加file_open_error(fp);  //文件是否打开失败fprintf(fp, "%d\t%s\t%s\t%s\t%s\t\n", a_1.account, a_1.password, a_1.name, a_1.gender, a_1.telNum);printf("||------------------------------------------||\n");printf("||             注  册  成  功               ||\n");printf("||------------------------------------------||\n");printf("|| 账号:%-8d  密码:%-16s   ||\n", a_1.account, a_1.password);printf("|| 姓名: %-8s  性别:%-4s               ||\n", a_1.name, a_1.gender);printf("|| 联系方式:%-16s               ||\n", a_1.telNum);printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);
}

注销管理员

void removeAdministrator()  //注销管理员
{char ch;int i = 0;int account;int len_1, len_2;  //记录密码个数, 记录密码合法字符个数char password[SIZE*2];Administrator * A;  //管理员Administrator * tail;  //指向尾部的指针FILE * fp;  //文件指针while(1){printf("||------------------------------------------||\n");printf("||    输入 0 可退出注销, 请输入 6 位数字    ||\n");printf("||------------------------------------------||\n");printf("||   管理员账号:  ");scanf("%d", &account);system("cls");  //清屏if(account == 0){return;}if(account<=100000 || account>999999){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||      账号格式错误, 请输入 6 位数字       ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}while(1){printf("||------------------------------------------||\n");printf("||   输入 0 可退出注销, 9-15 位字母或数字   ||\n");printf("||------------------------------------------||\n");printf("||   管理员密码:  ");scanf("%s", password);system("cls");  //清屏if(strcmp(password, "0") == 0){return;}len_1 = strlen(password);len_2 = strspn(password, str);if(len_1<9 || len_1>15 || len_2<9 || len_2>15){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||     密码格式错误, 9-15 位字母或数字      ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}A = (Administrator *)malloc(sizeof(Administrator));  //申请动态内存malloc_defeat(A);  //内存是否申请失败A->next = NULL;tail = A;  //指向尾部的指针fp = fopen("Administrator.txt", "r");  //可读写,写时清除原本内容file_open_error(fp);  //文件是否打开失败while(!feof(fp))  //fp==EOF 返回 1{Administrator * p;  //存放数据的指针p = (Administrator *)malloc(sizeof(Administrator));  //申请动态内存malloc_defeat(p);  //内存是否申请失败fscanf(fp,"%d\t%s\t%s\t%s\t%s\t\n", &p->account, p->password, p->name, p->gender, p->telNum);if((account == p->account) && (strcmp(password, p->password) == 0)){i = 1;  //删除计为 1continue;  //如果信息相同,则不接入链表}tail->next = p;  //接到表尾tail = p;  //循环至表尾tail->next = NULL;  //表尾表尾赋空}printf("||------------------------------------------||\n");if(i){printf("||             删  除  成  功               ||\n");}else{printf("||       无该管理员或管理员信息错误         ||\n");}printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);if(i == 0){admi_Destrong_List(A);  //摧毁链表return;}fp = fopen("Administrator.txt", "w");  //可读写,写时清除原本内容file_open_error(fp);  //文件是否打开失败tail = A->next;  //指向尾部的指针while(tail != NULL){fprintf(fp,"%d\t%s\t%s\t%s\t%s\t\n", tail->account, tail->password, tail->name, tail->gender, tail->telNum);tail = tail->next;  //继续写入下一个}admi_Destrong_List(A);  //摧毁链表fclose(fp);  //关闭文件
}

修改管理员密码

修改密码都要双重认证新密码是否相同。

void reviseAdministratorPassword()  //修改管理员密码
{char ch;int i = 0;int account;int len_1, len_2;  //记录密码个数, 记录密码合法字符个数char password[SIZE*2];char password_1[SIZE*2], password_2[SIZE*2];FILE * fp;  //文件指针Administrator * A;  //管理员Administrator * tail;  //指向尾部的指针while(1){printf("||------------------------------------------||\n");printf("||   输入 0 即可取消修改, 请输入 6 位数字   ||\n");printf("||------------------------------------------||\n");printf("||   管理员账号:  ");scanf("%d", &account);system("cls");  //清屏if(account == 0){return;}if(account<=100000 || account>999999){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||      账号格式错误, 请输入 6 位数字       ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}while(1){printf("||------------------------------------------||\n");printf("||   输入 0 可取消修改, 9-15 位字母或数字   ||\n");printf("||------------------------------------------||\n");printf("||   管理员密码:  ");scanf("%s", password);system("cls");  //清屏if(strcmp(password, "0") == 0){return;}len_1 = strlen(password);len_2 = strspn(password, str);if(len_1<9 || len_1>15 || len_2<9 || len_2>15){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||     密码格式错误, 9-15 位字母或数字      ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}fp = fopen("Administrator.txt", "r");  //可读写file_open_error(fp);  //文件是否打开失败A = (Administrator *)malloc(sizeof(Administrator));  //申请动态内存malloc_defeat(A);  //内存是否申请失败A->next = NULL;tail = A;  //指向尾部的指针while(!feof(fp))  //fp==EOF 返回 1{Administrator * p;  //存放数据的指针p = (Administrator *)malloc(sizeof(Administrator));  //申请动态内存malloc_defeat(p);  //内存是否申请失败fscanf(fp, "%d\t%s\t%s\t%s\t%s\t\n", &p->account, p->password, p->name, p->gender, p->telNum);while((account == p->account)&&(strcmp(password, p->password) == 0))  //账号密码相同{while(1){printf("||------------------------------------------||\n");printf("||   输入 0 可取消修改, 9-15 位字母或数字   ||\n");printf("||------------------------------------------||\n");printf("||   新密码:  ");scanf("%s", password_1);system("cls");  //清屏if(strcmp(password_1, "0") == 0){return;}len_1 = strlen(password_1);len_2 = strspn(password_1, str);if(len_1<9 || len_1>15 || len_2<9 || len_2>15){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||    新密码格式错误, 9-15 位字母或数字     ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}while(1){printf("||------------------------------------------||\n");printf("||   输入 0 可取消修改, 9-15 位字母或数字   ||\n");printf("||------------------------------------------||\n");printf("||   请再次输入新密码: ");scanf("%s", password_2);system("cls");  //清屏if(strcmp(password_2, "0") == 0){return;}len_1 = strlen(password_2);len_2 = strspn(password_2, str);if(len_1<9 || len_1>15 || len_2<9 || len_2>15){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||    新密码格式错误, 9-15 位字母或数字     ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}if(strcmp(password_1, password_2) == 0){i = 1;strcpy(p->password, password_2);}else{printf("||------------------------------------------||\n");printf("||            密  码  不  相  同            ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏}}tail->next = p;  //接到表尾tail = p;  //循环至表尾tail->next = NULL;  //表尾表尾赋空}printf("||------------------------------------------||\n");if(i){printf("||             修  改  成  功               ||\n");}else{printf("||       无该管理员或管理员信息错误         ||\n");}printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);if(i == 0){admi_Destrong_List(A);  //摧毁链表return;}fp = fopen("Administrator.txt", "w");  //可读写,写时清除原本内容file_open_error(fp);  //文件是否打开失败tail = A->next;  //指向尾部的指针while(tail != NULL){fprintf(fp,"%d\t%s\t%s\t%s\t%s\t\n", tail->account, tail->password, tail->name, tail->gender, tail->telNum);tail = tail->next;  //继续写入下一个}admi_Destrong_List(A);  //摧毁链表fclose(fp);  //释放文件指针
}

查询用户

根据用户姓名进行查询。目前只能用姓名,闲麻烦没有搞别的。

void SearrchCt()  //查询顾客
{customer u_1;  //顾客FILE * fp;char name[SIZE];fp = fopen("Registering.txt", "r");  //可读写file_open_error(fp);  //文件是否打开失败printf("||------------------------------------------||\n");printf("||   顾客姓名:  ");scanf("%s", name);system("cls");  //清屏while(!feof(fp))  //fp==EOF 返回 1{fscanf(fp,"%d\t%s\t%s\t%s\t%s\t%d\t\n",&u_1.account, u_1.password,u_1.name,u_1.gender,u_1.telNum, &u_1.balance);if(strcmp(name, u_1.name) == 0){printf("||------------------------------------------||\n");printf("|| 账号:%-8d  密码:%-16s   ||\n", u_1.account, u_1.password);printf("|| 姓名:%-8s  联系方式:%-11s    ||\n", u_1.name, u_1.telNum);printf("|| 性别:%-4s      余额:%-12d       ||\n", u_1.gender, u_1.balance);printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);  //关闭文件return;}}printf("||------------------------------------------||\n");printf("||             无  此  顾  客               ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);  //关闭文件
}

 


 

修改超级管理员密码

和修改管理员密码思路基本一致。

void changeSuAdminPassword()  //修改超级管理员密码
{char ch;char password_1[SIZE*2], password_2[SIZE*2];int len_1, len_2;  //记录密码个数, 记录密码合法字符个数SuperAdministrator sa_1;FILE * fp;fp = fopen("SuperAdministrator.txt", "r+");  //可读写,写时清除原本内容file_open_error(fp);  //文件是否打开失败fscanf(fp, "%d\t%s\t", &sa_1.account, sa_1.password);while(1){while(1){printf("||------------------------------------------||\n");printf("||   输入 0 可取消修改, 9-15 位字母或数字   ||\n");printf("||------------------------------------------||\n");printf("||   新密码:  ");scanf("%s", password_1);system("cls");  //清屏if(strcmp(password_1, "0") == 0){return;}len_1 = strlen(password_1);len_2 = strspn(password_1, str);if(len_1<9 || len_1>15 || len_2<9 || len_2>15){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||    新密码格式错误, 9-15 位字母或数字     ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}while(1){printf("||------------------------------------------||\n");printf("||   输入 0 可取消修改, 9-15 位字母或数字   ||\n");printf("||------------------------------------------||\n");printf("||   请再次输入新密码: ");scanf("%s", password_2);system("cls");  //清屏if(strcmp(password_2, "0") == 0){return;}len_1 = strlen(password_2);len_2 = strspn(password_2, str);if(len_1<9 || len_1>15 || len_2<9|| len_2>15){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||    新密码格式错误, 9-15 位字母或数字     ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}if(strcmp(password_1, password_2) == 0){strcpy(sa_1.password, password_2);fseek(fp, 0, SEEK_SET);fprintf(fp,"%d\t%s\t", sa_1.account, sa_1.password);printf("||------------------------------------------||\n");printf("||        修 改 成 功, 请 重 新 登 录       ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏break;}else{printf("||------------------------------------------||\n");printf("||            密  码  不  相  同            ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏}}fclose(fp);
}

商品相关函数菜单

就是选择对商品的操作。功能有点少了。

void relevant_Product()  //商品相关函数
{char ch, sel;while(1){printf("||------------------------------------------||\n");printf("||          商  品  相  关  菜  单          ||\n");printf("||------------------------------------------||\n");printf("||           【1】所有商品                  ||\n");printf("||           【2】添加商品                  ||\n");printf("||           【3】删除商品                  ||\n");printf("||           【4】修改商品价格              ||\n");printf("||           【5】添加商品折扣              ||\n");printf("||           【0】返回                      ||\n");printf("||------------------------------------------||\n");printf("||   请选择: ");while((sel = getchar()) == '\n');  //不管输入什么都只读取第一个字符(除换行)while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区(清空第一个字符后的每一个字符)system("cls");  //清屏switch(sel){case '1':showInfo();  //展示所有商品信息system("pause");system("cls");break;case '2':addProduct();  //添加商品break;case '3':deleteProduct();  //删除商品break;case '4':reviseProduct();  //修改商品价格break;case '5':merchandiseDiscount();  //添加商品折扣break;case '0':return;  //返回上一级default:input_error();  //输入错误显示}}
}

 


 

展示所有商品

void showInfo()  //展示所有商品信息
{FILE * fp;  //文件指针MobilePhone mp_1;fp = fopen("MobilePhone.txt", "r");  //只读,避免被修改file_open_error(fp);  //文件是否打开失败printf("||------------------------------------------||\n");printf("|| 编号      型号               价格    折扣||\n");while(!feof(fp)){fscanf(fp,"%d\t%s\t%d\t%lf\t%s\t\n", &mp_1.ID, mp_1.type, &mp_1.price, &mp_1.discount, mp_1.name);  //中转站printf("||%-8d%-7s%-15s%-8d%.2lf||\n", mp_1.ID, mp_1.type, mp_1.name, mp_1.price, mp_1.discount);}printf("||------------------------------------------||\n");fclose(fp);
}

 


 

添加商品

和注册管理员相似。

void addProduct()  //添加商品
{int len;char ch;FILE * fp;MobilePhone mp_1;while(1){printf("||------------------------------------------||\n");printf("||    输入 0 可取消添加, 请输入 6 位数字    ||\n");printf("||------------------------------------------||\n");printf("||    商品编号: ");scanf("%d", &mp_1.ID);system("cls");  //清屏if(mp_1.ID == 0)  //输入 0 返回上一级{return;}if(mp_1.ID<=100000 || mp_1.ID>999999)  //不是六位的数字{while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||      编号格式错误, 请输入 6 位数字       ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;  //账号格式正确}}while(1){printf("||------------------------------------------||\n");printf("||     输入 0 可取消添加, 8 位以内字母      ||\n");printf("||------------------------------------------||\n");printf("||     商品品牌: ");scanf("%s", mp_1.type);system("cls");  //清屏if(strcmp(mp_1.type, "0") == 0)  //输入 0 返回上一级{return;}len = strlen(mp_1.type);if(len >= 8){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||        品牌格式错误, 8 位以内字母        ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;  //账号格式正确}}printf("||------------------------------------------||\n");printf("||    商品型号:  ");scanf("%s", mp_1.name);system("cls");  //清屏printf("||------------------------------------------||\n");printf("||    商品价格:  ");scanf("%d", &mp_1.price);system("cls");  //清屏mp_1.discount = 1.0;fp = fopen("MobilePhone.txt", "a");  //只写,追加file_open_error(fp);  //文件是否打开失败fprintf(fp,"%d\t%s\t%d\t%lf\t%s\t\n", mp_1.ID, mp_1.type, mp_1.price, mp_1.discount, mp_1.name);printf("||------------------------------------------||\n");printf("||             添  加  成  功               ||\n");printf("||------------------------------------------||\n");printf("|| 编号      型号               价格    折扣||\n");printf("||%-8d%-7s%-15s%-8d%.2lf||\n", mp_1.ID, mp_1.type, mp_1.name, mp_1.price, mp_1.discount);printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);
}

删除商品

void deleteProduct()  //删除商品
{char ch;int i = 0;int ID;MobilePhone * MP;  //商品MobilePhone * tail;  //指向尾部的指针FILE * fp;  //文件指针MP = (MobilePhone *)malloc(sizeof(MobilePhone));  //申请动态内存if(MP == NULL){printf("||------------------------------------------||\n");printf("||          内  存  申  请  失  败          ||\n");printf("||------------------------------------------||\n");exit(0);}MP->next = NULL;tail = MP;  //指向尾部的指针fp = fopen("MobilePhone.txt", "r");  //可读写,写时清除原本内容file_open_error(fp);  //文件是否打开失败while(1){printf("||------------------------------------------||\n");printf("||    输入 0 可取消删除, 请输入 6 位数字    ||\n");printf("||------------------------------------------||\n");printf("||    商品编号: ");scanf("%d", &ID);system("cls");  //清屏if(ID == 0)  //输入 0 返回上一级{return;}if(ID<=100000 || ID>999999)  //不是六位的数字{while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||      编号格式错误, 请输入 6 位数字       ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;  //账号格式正确}}while(!feof(fp))  //fp==EOF 返回 1{MobilePhone * p;  //存放数据的指针p = (MobilePhone *)malloc(sizeof(MobilePhone));  //申请动态内存if(p == NULL){printf("||------------------------------------------||\n");printf("||          内  存  申  请  失  败          ||\n");printf("||------------------------------------------||\n");exit(0);}fscanf(fp,"%d\t%s\t%d\t%lf\t%s\t\n",&p->ID,p->type,&p->price,&p->discount,p->name);if(ID == p->ID){i = 1;  //删除计为 1continue;  //如果信息相同,则不接入链表}tail->next = p;  //接到表尾tail = p;  //循环至表尾tail->next = NULL;  //表尾表尾赋空}printf("||------------------------------------------||\n");if(i){printf("||             删  除  成  功               ||\n");}else{printf("||         无该商品或商品编号错误           ||\n");}printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);if(i == 0)  //摧毁指针,并且返回{prod_Destrong_List(MP);  //销毁链表return;}fp = fopen("MobilePhone.txt", "w");  //可读写,写时清除原本内容file_open_error(fp);  //文件是否打开失败tail = MP->next;  //指向尾部的指针while(tail != NULL){fprintf(fp,"%d\t%s\t%d\t%lf\t%s\t\n", tail->ID, tail->type, tail->price, tail->discount, tail->name);tail = tail->next;  //继续写入下一个}prod_Destrong_List(MP);  //销毁链表fclose(fp);  //释放文件指针
}

修改商品价格

void reviseProduct()  //修改商品价格
{char ch;int i = 0;int ID;MobilePhone * MP;  //商品MobilePhone * tail;  //指向尾部的指针FILE * fp;  //文件指针MP = (MobilePhone *)malloc(sizeof(MobilePhone));  //申请动态内存if(MP == NULL){printf("||------------------------------------------||\n");printf("||          内  存  申  请  失  败          ||\n");printf("||------------------------------------------||\n");exit(0);}MP->next = NULL;tail = MP;  //指向尾部的指针while(1){printf("||------------------------------------------||\n");printf("||    输入 0 可取消修改, 请输入 6 位数字    ||\n");printf("||------------------------------------------||\n");printf("||    需改商品编号:");scanf("%d", &ID);system("cls");  //清屏if(ID == 0)  //输入 0 返回上一级{return;}if(ID<=100000 || ID>999999)  //不是六位的数字{while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||      编号格式错误, 请输入 6 位数字       ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;  //账号格式正确}}fp = fopen("MobilePhone.txt", "r");  //可读写file_open_error(fp);  //文件是否打开失败while(!feof(fp))  //fp==EOF 返回 1{MobilePhone * p;  //存放数据的指针p = (MobilePhone *)malloc(sizeof(MobilePhone));  //申请动态内存if(p == NULL){printf("||------------------------------------------||\n");printf("||          内  存  申  请  失  败          ||\n");printf("||------------------------------------------||\n");exit(0);}fscanf(fp,"%d\t%s\t%d\t%lf\t%s\t\n",&p->ID,p->type,&p->price,&p->discount,p->name);if(ID == p->ID)  //编号相同{printf("||------------------------------------------||\n");printf("||            修  改  后  价  格            ||\n");printf("||------------------------------------------||\n");printf("||    商品价格: ");scanf("%d", &p->price);system("cls");  //清屏i = 1;}tail->next = p;  //接到表尾tail = p;  //循环至表尾tail->next = NULL;  //表尾表尾赋空}printf("||------------------------------------------||\n");if(i){printf("||             修  改  成  功               ||\n");}else{printf("||         无该商品或商品编号错误           ||\n");}printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);  //关闭文件if(i == 0)  //销毁链表,并且返回{prod_Destrong_List(MP);return;}fp = fopen("MobilePhone.txt", "w");  //可读写,写时清除原本内容file_open_error(fp);  //文件是否打开失败tail = MP->next;  //指向尾部的指针while(tail != NULL){fprintf(fp, "%d\t%s\t%d\t%lf\t%s\t\n", tail->ID, tail->type, tail->price, tail->discount, tail->name);tail = tail->next;  //继续写入下一个}prod_Destrong_List(MP);  //销毁链表fclose(fp);  //释放文件指针
}

添加商品折扣

用小数代替,相当于1是不打折,0.9是9折,以此类推。

void merchandiseDiscount()   //添加商品折扣
{char ch;int i = 0;int ID;MobilePhone * MP;  //商品MobilePhone * tail;  //指向尾部的指针FILE * fp;  //文件指针MP = (MobilePhone *)malloc(sizeof(MobilePhone));  //申请动态内存if(MP == NULL){printf("||------------------------------------------||\n");printf("||         内  存  申  请  失  败           ||\n");printf("||------------------------------------------||\n");exit(0);}MP->next = NULL;tail = MP;  //指向尾部的指针fp = fopen("MobilePhone.txt", "r");  //可读写file_open_error(fp);  //文件是否打开失败while(1){printf("||------------------------------------------||\n");printf("||    输入 0 可取消添加, 请输入 6 位数字    ||\n");printf("||------------------------------------------||\n");printf("||    商品编号: ");scanf("%d", &ID);system("cls");  //清屏if(ID == 0)  //输入 0 返回上一级{return;}if(ID<=100000 || ID>999999)  //不是六位的数字{while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区printf("||------------------------------------------||\n");printf("||      编号格式错误, 请输入 6 位数字       ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;  //账号格式正确}}while(!feof(fp))  //fp==EOF 返回 1{MobilePhone * p;  //存放数据的指针p = (MobilePhone *)malloc(sizeof(MobilePhone));  //申请动态内存if(p == NULL){printf("||------------------------------------------||\n");printf("||          内  存  申  请  失  败          ||\n");printf("||------------------------------------------||\n");exit(0);}fscanf(fp,"%d\t%s\t%d\t%lf\t%s\t\n",&p->ID,p->type,&p->price,&p->discount,p->name);if(ID == p->ID)  //编号相同{while(1){printf("||------------------------------------------||\n");printf("||        添 加 折 扣, 小 数(例: 0.9)       ||\n");printf("||------------------------------------------||\n");printf("||      折扣:  ");scanf("%lf", &p->discount);system("cls");  //清屏if(p->discount<=0 || p->discount>1){while((ch = getchar()) != '\n' && ch != EOF);  //清空缓冲区(清空第一个字符后的每一个字符)printf("||------------------------------------------||\n");printf("||    折扣格式错误, 请输入小于 1 的小数     ||\n");printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏continue;}else{break;}}i = 1;  //添加成功}tail->next = p;  //接到表尾tail = p;  //循环至表尾tail->next = NULL;  //表尾表尾赋空}printf("||------------------------------------------||\n");if(i){printf("||             添  加  成  功               ||\n");}else{printf("||         无该商品或商品编号错误           ||\n");}printf("||------------------------------------------||\n");system("pause");  //暂停system("cls");  //清屏fclose(fp);  //关闭文件if(i == 0)  //销毁链表,并且返回{prod_Destrong_List(MP);return;}fp = fopen("MobilePhone.txt", "w");  //可读写,写时清除原本内容file_open_error(fp);  //文件是否打开失败tail = MP->next;  //指向尾部的指针while(tail != NULL){fprintf(fp,"%d\t%s\t%d\t%lf\t%s\t\n", tail->ID, tail->type, tail->price, tail->discount, tail->name);tail = tail->next;  //继续写入下一个}prod_Destrong_List(MP);  //销毁链表fclose(fp);  //释放文件指针
}

假二维码

其实这个二维码只是一个用循环结合if语句一个格子一个格子的打印出来的图像,利用随机数,除了固定位置,其余位置每次打印都会不一样。

所以说,是扫不出来的哦。

不过这个函数在这个项目里面没有调用,原本是购买商品时的支付二维码和余额充值的支付二维码,属于是对用户的操作了,就没有调用。感兴趣的小伙伴可以复制打印一下。

void Payment_QR_code()  //支付二维码
{const int n = 25;int i, j;srand((unsigned)time(NULL));  //种子库,成逐渐增大或逐渐减小for(i = 1; i <= n; i++){for(j = 1; j <= n; j++){//定黑if((i==1&&j<=7)||(i==1&&j>=n-6)||(i==7&&j<=7)||(i==7&&j>=n-6)){printf(ch_1);continue;}if((j==1&&i<=7)||(j==1&&i>=n-6)||(j==7&&i<=7)||(j==7&&i>=n-6)){printf(ch_1);continue;}if(((i==n-6||i==n)&&j<=7)||((j==n-6||j==n)&&i<=7)){printf(ch_1);continue;}if((i==3||i==4||i==5||i==n-2||i==n-3||i==n-4)&&(j==3||j==4||j==5)){printf(ch_1);continue;}if((i==3||i==4||i==5)&&(j==3||j==4||j==5||j==n-2||j==n-3||j==n-4)){printf(ch_1);continue;}if((i==n-4||i==n-8)&&(j<=n-4&&j>=n-8)){printf(ch_1);continue;}if((j==n-4||j==n-8)&&(i<=n-4&&i>=n-8)){printf(ch_1);continue;}if(i==n-6&&j==n-6){printf(ch_1);continue;}//定白if(i==2&&((j>=2&&j<=6)||(j<=n-1&&j>=n-5))){printf(ch_2);continue;}if(i==6&&((j>=2&&j<=6)||(j<=n-1&&j>=n-5))){printf(ch_2);continue;}if(j==2&&((i>=2&&i<=6)||(i<=n-1&&i>=n-5))){printf(ch_2);continue;}if(j==6&&((i>=2&&i<=6)||(i<=n-1&&i>=n-5))){printf(ch_2);continue;}if(i==8&&(j<=8||j>=n-7)){printf(ch_2);continue;}if(j==8&&(i<=8||i>=n-7)){printf(ch_2);continue;}if(i==n-7&&((j<=8)||(j<=n-5&&j>=n-7))){printf(ch_2);continue;}if(j==n-7&&((i<=8)||(i<=n-5&&i>=n-7))){printf(ch_2);continue;}if(i==n-5&&((j<=8)||(j<=n-5&&j>=n-7))){printf(ch_2);continue;}if(j==n-5&&((i<=8)||(i<=n-5&&i>=n-7))){printf(ch_2);continue;}if(i==n-1&&(j<=6&&j>=2)){printf(ch_2);continue;}if(j==n-1&&(i<=6&&i>=2)){printf(ch_2);continue;}else  //随机{if(rand()%2){printf(ch_1);continue;}else{printf(ch_2);continue;}}}printf("\n");}system("pause");  //暂停system("cls");  //清屏
}

 


给个赞吧OAO,谢谢!

完结......

这篇关于电商系统之超管-管理员-商品(C语言)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/385262

相关文章

Go 语言中的select语句详解及工作原理

《Go语言中的select语句详解及工作原理》在Go语言中,select语句是用于处理多个通道(channel)操作的一种控制结构,它类似于switch语句,本文给大家介绍Go语言中的select语... 目录Go 语言中的 select 是做什么的基本功能语法工作原理示例示例 1:监听多个通道示例 2:带

利用Python快速搭建Markdown笔记发布系统

《利用Python快速搭建Markdown笔记发布系统》这篇文章主要为大家详细介绍了使用Python生态的成熟工具,在30分钟内搭建一个支持Markdown渲染、分类标签、全文搜索的私有化知识发布系统... 目录引言:为什么要自建知识博客一、技术选型:极简主义开发栈二、系统架构设计三、核心代码实现(分步解析

C语言函数递归实际应用举例详解

《C语言函数递归实际应用举例详解》程序调用自身的编程技巧称为递归,递归做为一种算法在程序设计语言中广泛应用,:本文主要介绍C语言函数递归实际应用举例的相关资料,文中通过代码介绍的非常详细,需要的朋... 目录前言一、递归的概念与思想二、递归的限制条件 三、递归的实际应用举例(一)求 n 的阶乘(二)顺序打印

Python FastAPI+Celery+RabbitMQ实现分布式图片水印处理系统

《PythonFastAPI+Celery+RabbitMQ实现分布式图片水印处理系统》这篇文章主要为大家详细介绍了PythonFastAPI如何结合Celery以及RabbitMQ实现简单的分布式... 实现思路FastAPI 服务器Celery 任务队列RabbitMQ 作为消息代理定时任务处理完整

Linux系统中卸载与安装JDK的详细教程

《Linux系统中卸载与安装JDK的详细教程》本文详细介绍了如何在Linux系统中通过Xshell和Xftp工具连接与传输文件,然后进行JDK的安装与卸载,安装步骤包括连接Linux、传输JDK安装包... 目录1、卸载1.1 linux删除自带的JDK1.2 Linux上卸载自己安装的JDK2、安装2.1

C语言中的数据类型强制转换

《C语言中的数据类型强制转换》:本文主要介绍C语言中的数据类型强制转换方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录C语言数据类型强制转换自动转换强制转换类型总结C语言数据类型强制转换强制类型转换:是通过类型转换运算来实现的,主要的数据类型转换分为自动转换

利用Go语言开发文件操作工具轻松处理所有文件

《利用Go语言开发文件操作工具轻松处理所有文件》在后端开发中,文件操作是一个非常常见但又容易出错的场景,本文小编要向大家介绍一个强大的Go语言文件操作工具库,它能帮你轻松处理各种文件操作场景... 目录为什么需要这个工具?核心功能详解1. 文件/目录存javascript在性检查2. 批量创建目录3. 文件

Linux系统之主机网络配置方式

《Linux系统之主机网络配置方式》:本文主要介绍Linux系统之主机网络配置方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、查看主机的网络参数1、查看主机名2、查看IP地址3、查看网关4、查看DNS二、配置网卡1、修改网卡配置文件2、nmcli工具【通用

Linux系统之dns域名解析全过程

《Linux系统之dns域名解析全过程》:本文主要介绍Linux系统之dns域名解析全过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、dns域名解析介绍1、DNS核心概念1.1 区域 zone1.2 记录 record二、DNS服务的配置1、正向解析的配置

C语言实现两个变量值交换的三种方式

《C语言实现两个变量值交换的三种方式》两个变量值的交换是编程中最常见的问题之一,以下将介绍三种变量的交换方式,其中第一种方式是最常用也是最实用的,后两种方式一般只在特殊限制下使用,需要的朋友可以参考下... 目录1.使用临时变量(推荐)2.相加和相减的方式(值较大时可能丢失数据)3.按位异或运算1.使用临时