表达式在数组中必须有指向对象的指针类型错误

Expression must have a pointer-to-object type error in an array

#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){,我知道这是因为 vector 被定义为 {5,{3, 23, 56, 109, 238}} 但我真的不知道如何检查 n 是否属于 vect。

您需要使用成员 vector,而不是结构变量本身。

改变

 while(vect[i] <= n)

while(vect.vector[i] <= n)