首页上一页 1 下一页尾页 3 条记录 1/1页
vc++
发表在C语言图书答疑
2009-10-29
是否精华
是
否
版块置顶:
是
否
#include <stdio.h>
#include <string.h>
class Cuser
{
public:
char username[128];
char password[128];
bool login()
{
if(strcmp(username,"MR")==0&&strcmp(password,"KJ")==0)
{
printf("登录成功:\n");
return true;
}
else{
printf("登陆失败:\n");
return false;
}
}
};
int main()
{
Cuser user;
//user.username="MR";
//user.password="KJ";我这样赋值为什么不正确呢?
strcpy(user.username,"MR");
strcpy(user.password,"KJ");
user.login();
return 0;
}
#include <string.h>
class Cuser
{
public:
char username[128];
char password[128];
bool login()
{
if(strcmp(username,"MR")==0&&strcmp(password,"KJ")==0)
{
printf("登录成功:\n");
return true;
}
else{
printf("登陆失败:\n");
return false;
}
}
};
int main()
{
Cuser user;
//user.username="MR";
//user.password="KJ";我这样赋值为什么不正确呢?
strcpy(user.username,"MR");
strcpy(user.password,"KJ");
user.login();
return 0;
}