问题描述
我实际上是编程新手,这是我真正尝试解决的第一件事,但我无法解决。问题是,当我创建一个新帐户时,没有更改第一个帐户昵称的最后一个帐户的密码。我认为您应该运行代码,创建一个新帐户,然后按5以查看nicks数组上的第一个昵称。是因为我还是开发C ++而引起的问题。我不知道。
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int right=3,choice1,choice2,choice3,nicksdata=2,passwordsdata=2;
char nick[20],password[16],user[20];
char nicks[nicksdata][20]={"emin","ahmet"};
char passwords[passwordsdata][16]={"1234","1a2s3d"};
system("cls");
printf("Hello,welcome.\n");
entryagain : printf("Press 1 to login your account.\n");
printf("Press 2 to create an account.\n");
printf("Press 0 (zero) to shutdown.\n");
scanf("%d",&choice1);
switch(choice1)
{
case 1 : goto login;
case 2 : break;
case 0 : printf("Shutting down."); return 0;
default :
{
system("cls");
printf("You have entered an invalid character,please try again.\n\n");
goto entryagain;
}
}
{
system("cls");
nicksdata++;
passwordsdata++;
printf("Nickname : "); scanf("%s",&nicks[nicksdata-1]);
printf("Password : "); scanf("%s",&passwords[passwordsdata-1]);
system("cls");
printf("Hello,\nWelcome %s\n",nicks[nicksdata-1]);
goto system;
}
///////
login :
{
loginagain : system("cls");
printf("Nickname : "); scanf("%s",&nick);
printf("Password : "); scanf("%s",&password);
for(int i=0;i<nicksdata;i++)
{
if(strcmp(nicks[i],nick)==0 && strcmp(passwords[i],password)==0)
{
system("cls");
printf("Hello,nicks[i]);
strcpy(user,nicks[i]);
goto system;
}
else
{
printf("Nickname or password is wrong. \nPlease try again.(Rights you have : %d)\n",right);
right--;
if(right==0)
{
system("cls");
printf("You have used all your rights.\n\nShutting down."); return 0;
}
printf("Press 1 to try again."); scanf("%d",&choice2);
switch(choice2)
{
case 1 : goto loginagain;
case 2 : printf("Shutting down."); return 0;
default : printf("You have entered an invalid character,please try again.");
}
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
system :
{
systemagain : printf("\n Computer - 1");
printf("\n Games - 2");
printf("\n Notes - 3");
printf("\n Shutdown - 4");
printf("\n\n Choice-----:");
scanf("%d",&choice3);
switch(choice3)
{
case 1 : goto computer;
case 2 : goto games;
case 3 : goto notes;
case 4 : system("cls"); printf("Shutting down."); return 0;
case 5 : printf("%s",nicks[0]); // isn't it should be "emin" ???
return 0;
default : system("cls"); goto systemagain;
}
computer :
{
system("cls");
printf("computer");
return 0;
}
games :
{
system("cls");
printf("games");
return 0;
}
notes :
{
system("cls");
printf("notes");
return 0;
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)