【发布时间】:2021-04-28 15:34:55
【问题描述】:
我正在编写一个程序来读取密码,直到密码正确为止。我对如何在其中使用循环感到困惑。
#include <stdio.h>
#include <cs50.h> //cs library Harvard for getting input of string from the user
#include <string.h>
int main(void)
{
string first="hello";
string check = get_string("Hello! \n, enter password ,"); //gets the string, input from the user.
if (strcmp(first, check) == 0)
{
printf("Welcome \n");
}
else
{
printf("\n wrong pwd, good bye \n");
}//I want to put this part in loop until the correct pwd is entered.
}
【问题讨论】: