I want to make a Struct of an array of structs.I tried to change one of the structs field variables of the array of structs.Node( [Node(1,[]) | | | ] )** I don't understand why my struct array hope first node count isn't equal to 1. When I printf("%d\n",start->innercount); I expect 1 because my node1 fields innercount has been initialized to 1 and I have initialized hope struct fields to 3,node1,1.0 .
#include <stdio.h>
struct Mynode {
int innercount;
char token[20];
};
struct MyData {
int count;
struct Mynode hope[20];
float average;
};
int main(){
struct Mynode node1[1] = {1, "helo"};
struct MyData data[1] = {3, node1, 1.0};
struct MyData* ptr = data;
struct MyData* endPtr = data + sizeof(data) / sizeof(data[0]);
while ( ptr < endPtr ){
struct Mynode* start = ptr->hope;
struct Mynode* end = ptr->hope + sizeof(ptr->hope) / sizeof(ptr->hope[0]);
while(start < end){
printf("%d\n",start->innercount);
start++;
}
ptr++;
}
return 0;
}