gpt4 book ai didi

c++ - Do-While 循环 C++

转载 作者:行者123 更新时间:2023-11-28 06:00:33 25 4
gpt4 key购买 nike

<分区>

我是 C++ 的新手,对于我的作业,他们希望我创建一个函数来获取我在此处完成的用户输入:(classList 是一个数组)

public:
void userInput() {

string enterAgain;

do {

cout << "Enter the students name: " << name;
cin >> name;

cout << "Enter the number of classes the student is enrolled in: " << numClasses;
cin >> numClasses;

for (int i = 0; i < numClasses; i++) {
cout << "Enter the class list: " << (i+1) << classList;
cin >> classList;
i++;
}

cout << "Would you like to enter again (y for yes): " << enterAgain;
cin >> enterAgain;

} while (enterAgain == "Y" || enterAgain == "y");

}

当我运行该程序时,它会要求用户输入学生姓名,然后是他们正在类的人数,但是当它要求用户输入类(class)列表时,它会显示如下内容:

Enter the class list: 0x7fff536d1b78

但除此之外它不会让我输入任何内容。我搜索了几个小时试图纠正这个问题,我希望有人能指出我正确的方向来纠正这个问题。谢谢!

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com