代码没什么问题啊
在Gcc下是可以编译通过的
是不是你的编译器有问题
改成这样 应该更通用一些。
#include
#include
using namespace std;
struct JG
{
char name[20];
char word[40];
int password;
};
int main()
{
JG mm = {};
cout << "Enter your name please!\n";
cin.getline( mm.name, 20);
cout << "This is your name:" << mm.name << endl;
cout << "Enter your code!\n";
cin >> mm.word;
mm.password = mm.word[0] + mm.word[1] * mm.word[2] * mm.word[3] - 1000000;
cout << "This is your password,please keep it in mind!" << endl << mm.password << endl;
cin.get();
}