【发布时间】:2021-02-23 04:25:32
【问题描述】:
#include <stdio.h>
#define DIM 10
typedef struct{
int nelem; //amount of numbers in the array
int vector[DIM];
}t_vector_int;
int main(){
t_vector_int vect={5,{3, 23, 56, 109, 238}};
int n, i=0;
printf(" Vector inicial: 3, 23, 56, 109, 238\n\nIntroduzca un valor entero: ");
scanf("%d", &n);
while(vect[i] <= n){
}
return 0;
}
我在第 15 行得到错误 while(vect[i] <= n){,我知道这是因为 vect 被定义为 {5,{3, 23, 56, 109, 238}},但我真的不知道如何检查 n 是否属于 vect。
【问题讨论】: