你看看我给你的用法:
程序代码:
函数Get_Password()是把正确的密码字符串地址作为参数送给函数,与用户输入的字符串比较,看是否吻合,吻合就返回真,否则返回假。
你再看看你自己用的那个,它实现的功能的是什么,满足你的主程序需要吗?

int main(void) { const char* correct_password = "Hello, world"; // 这个是正确密码 printf_s("Please input your password: "); // 当输入密码的函数返回真时,输出correct,返回假时,输出error,这就是用法! // 如果要判断多次,就使用多次,每次返回结果都计数,这样你的计数器才用得上 printf_s("\nYour password is %s.\n", Get_Password(correct_password) ? "correct" : "error"); _getch(); return 0; }
函数Get_Password()是把正确的密码字符串地址作为参数送给函数,与用户输入的字符串比较,看是否吻合,吻合就返回真,否则返回假。
你再看看你自己用的那个,它实现的功能的是什么,满足你的主程序需要吗?

授人以渔,不授人以鱼。