gpt4 book ai didi

尝试在 xcode 中退出程序时出现 C++ 11db 错误。初学者级

转载 作者:行者123 更新时间:2023-11-30 04:44:52 24 4
gpt4 key购买 nike

我正处于回答彩票 HW 问题的开始步骤,但是,当我调用 getLottoPicks 函数时,它会抛出程序并显示 11db 错误。因此,当程序首次运行并且您使用“q”或“Q”退出时,它可以正常工作,但是如果用户通过该程序一次然后尝试退出,我会收到 11db 错误。我尝试在各种地方粘贴 cin.ignore() 但没有帮助。

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cctype>

using namespace std;

void menu();
int getLottoPicks(int[], int);

int main()
{
char choice;
const int SIZE = 6;
int UserTicket[SIZE];
int WinningNums[SIZE];
string name;

do
{
menu();
cin >> choice;
cout << endl;
cin.ignore();

switch (choice)
{
case '1':
cout << "Please enter your name: ";
getline(cin, name);

getLottoPicks(UserTicket,SIZE);

for(int i = 0; i <= SIZE; i++)
{
cout << UserTicket[i];
cout << ", ";
}
cout << endl <<endl;
break;
case 'q':
case 'Q':
cout << "You have chosen to quit the program. Thank you for using!\n";
break;
default:
cout << "Invalide Selection.\n";
break;
}

}while (choice != 'q' && choice != 'Q');

return 0;
}

void menu()
{
cout << "1) Play Lotto\n";
cout << "q) Quit Program\n";
cout << "Please make a selection: \n";
}

int getLottoPicks(int nums[], int size)
{
cout << "Please enter your 7 lotto number picks between 1 and 40.\n";

for(int i = 0; i <= size; i++)
{
cout << "Please pick #" << i + 1 << ": ";
cin >> nums[i];
cout << endl;
}
return nums[0], nums[1], nums[2], nums[3], nums[4], nums[5], nums[6];
}

/* 这是程序的运行1) 玩乐透q) 退出程序请选择:1

请输入您的姓名:asdf请在 1 到 40 之间输入您选择的 7 个乐透号码。请选择#1: 1

请选择#2:1

请选择#3:1

请选择#4:1

请选择#5:1

请选择#6:1

请选择#7:1

1, 1, 1, 1, 1, 1, 1,

1) 玩乐透q) 退出程序请选择:q

您已选择退出程序。感谢您的使用!(11db) <----- 这是我得到的绿色。在我用 Cmd 手动关闭程序之前,程序不会退出。*/

最佳答案

(lldb)LLDB 的命令提示符调试器,而不是错误代码。您的程序已崩溃,可能是因为您正在将 7 个元素加载到大小为 6 的数组中。

关于尝试在 xcode 中退出程序时出现 C++ 11db 错误。初学者级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57516592/

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