#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;
}
I get the error in line 15 while(vect[i] <= n){
, I know it's because vect is defined as {5,{3, 23, 56, 109, 238}}
but don't really know how to chech if n belongs to vect.
You need to use the member vector
, not the structure variable itself.
Change
while(vect[i] <= n)
to
while(vect.vector[i] <= n)