gpt4 book ai didi

c - Xcode 似乎无法在 C 中使用数组

转载 作者:太空宇宙 更新时间:2023-11-04 02:29:34 25 4
gpt4 key购买 nike

这很可能是用户错误,因为我是 Xcode 的新手,但我无法弄清楚。希望你们中的一个可以。

我正在尝试使用以下代码添加一个数组:

int ArraySum (int MyArray [], int size) {
int sum = 0;
for (int i = 0; i< size; i++) {
sum = sum + MyArray [i];
}
return sum;
}

int main (){
int mynumberarray [6] = {1,2,3,4,5,6};
int the_sum = ArraySum (mynumberarray, 6);
printf ("The Sum is = %d \n", the_sum);
return 0;
}

当我在 Xcode 中单击构建和运行按钮时,我得到的唯一输出是 (lldb)。

这通常会让我相信我在某处犯了错误,但当我通过终端运行代码时,它运行完美并给出了正确的总和。

有人可以帮我吗?这不是一个孤立的事件,我在 Xcode 中使用数组时遇到了几个问题,这些问题在终端中执行时运行良好。

截图:

enter image description here

最佳答案

您在 Xcode 项目中设置了断点,因此程序在第一个断点处暂停并为您提供 (lldb) 调试器提示。禁用断点并运行,一切都应该按预期运行。您可以手动禁用每个断点(通过单击它 - 然后它应该变暗),或转到菜单栏中的 Debug => Disable Breakpoints

关于c - Xcode 似乎无法在 C 中使用数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45454319/

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