⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regist.c

📁 linux下开发的一款类似于QQ的网络聊天室
💻 C
字号:
#include "main.h"#define P_MAX 1024int regist(char *name,char *passwd){	FILE *fp;	char *p;	char buff[P_MAX];	if((p=strchr(name,'\n'))!=NULL)		*p='\0';	if((p=strchr(passwd,'\n'))!=NULL)		*p='\0';	if((p=strchr(name,':'))!=NULL)	{		printf("username error!\n");		exit(1);	}	if((p=strchr(passwd,':'))!=NULL)	{		printf("password error!\n");		exit(1);	}	fp=fopen("passwd","r");	if(fp==NULL)	{		printf("open passwd error!\n");		exit(1);	}	while((fgets(buff,sizeof(buff),fp))!=NULL)	{		p=strchr(buff,':');		*p='\0';		if(strcmp(buff,name)==0)		{			return(-1);		}	}	fclose(fp);	fp=fopen("passwd","a");	if(fp==NULL)	{		printf("open passwd.txt error!\n");		exit(1);	}	strcpy(buff,name);	strcat(buff,":");	strcat(buff,passwd);	strcat(buff,"\n");	fputs(buff,fp);	fclose(fp);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -