gpt4 book ai didi

c - 试图找出导致 sigsegv 故障的原因

转载 作者:行者123 更新时间:2023-12-02 21:30:08 25 4
gpt4 key购买 nike

#include <stdio.h>
#include <stdlib.h>

int main(void) {


long size = 10000000;

long i = 0;

while (i < size) {
printf("%d\n", i);
i++;


}

return EXIT_SUCCESS;
}

/*
++++++++++++++++++++++++++++++++++++++++++++++++++++++


but commenting out printf, i get no error - even traced in a debugger and jumping to breaks after the while loop, i am able to get i reach the 10 billion mark.
just like below -


++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/


#include <stdio.h>
#include <stdlib.h>

int main(void) {


long size = 10000000;

long i = 0;

while (i < size) {
//printf("%d\n", i);
i++;


}

return EXIT_SUCCESS;
}

最佳答案

您对 long 使用了错误的说明符,这会调用未定义的行为。请改用 %ld

关于c - 试图找出导致 sigsegv 故障的原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22510131/

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