【发布时间】:2023-02-25 05:12:50
【问题描述】:
我有一个函数,它在 2 个数组中给出数字,但第二个数组不接受所有给定的数字。任何想法发生了什么?
我试试这个
struct array
{
int (*list)[N];
int (*mlist)[N];
};
int input(struct array x){
int i, j;
printf("Give the intiger numbrs for the first array: ");
for(i = 0; i< N; i++){
scanf("%d", *(x.list+i));
}
printf("Give the intiger numbrs for the second array: ");
for(j = 0; j< N; j++){
scanf("%d", *(x.mlist+j));
}
}
int main(){
struct array x;
input(x);
return 0;
}
【问题讨论】:
-
您的结构包含两个指向数组的指针,但您从未为它们分配任何内存。
-
我想知道是什么触发了blackgreen 删除给定的答案?
-
@chux-ReinstateMonica 啊...答案可能被确定为 ChatGPT 生成的答案。
-
@chux-ReinstateMonica 我也是。我发现有时很难发现,而且我也不会猜到这是其中之一 - 但我读到@meta,mods 已经变得非常擅长发现这些答案。我认为这需要一些练习。 :)
-
@TedLyngmo 评论清洁器通过:哔 - 哔。
标签: c