关于用C三维阵列的问题 [英] Questions about 3D arrays in C
本文介绍了关于用C三维阵列的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用空的假设,我不知道的howmany存储在阵列[CR项目。 Kinjal迪克西特]
I use empty to assume that i don't know howmany items stored in the arrays[cr. Kinjal Dixit]
推荐答案
您正在访问您的阵列外的界限。
You are accessing your array out-of-bounds.
的例如的
char name[HAVE_DISCOUNT][HAVENT_DISCOUNT][MAX_LENGTH];
//...
sscanf( input, "%s", name[i][HAVENT_DISCOUNT] ); // <-- out of bounds
您必须索引正整数小于该维度的尺寸阵列。
You have to index your array with positive integers less than the size of that dimension.
也许你想是这样的:
typedef enum {
HAVE_DISCOUNT,
HAVENT_DISCOUNT,
NUM_DISCOUNT_TYPES
} DiscountType;
const int MAX_NAMES = 32;
char name[MAX_NAMES][NUM_DISCOUNT_TYPES][MAX_LENGTH];
// etc...
这篇关于关于用C三维阵列的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文