gpt4 book ai didi

c - 检查索引是否为 "out of bounds"的最佳方法

转载 作者:行者123 更新时间:2023-11-30 16:13:22 24 4
gpt4 key购买 nike

如果我有以下循环运行的语句:

rows[row_num++] = row;

检查当前行数组的索引是否在数组长度内的最佳方法是什么?即,防止段错误。

最佳答案

你可以像这样在运行时找到数组的大小

array_size = sizeof(rows)/sizeof(rows[0]);

关于c - 检查索引是否为 "out of bounds"的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58055093/

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