关于登录的c程序,关于文件操作的,
程序代码:
#include<stdio.h> #include<string.h> #include<iostream.h> void main() { char *user; char keyword[16]={'\o'}; FILE *fp; printf("user:"); user=(char *)malloc(10*sizeof(char)); scanf("%s",user); if((fp=fopen(user,"r+"))==NULL) { printf("用户名错误!"); exit (1); } printf("keyword:"); scanf("%s",keyword); char keyword1[16]; fgets(keyword1,strlen(keyword),fp); if(strcmp(keyword,keyword1)==0) printf("welcome to here!"); else printf("密码错误!"); }
确定输入的密码和打的密码相同,但是提示密码错误。求助!