Intuitively below should seemingly work, 1) define a structure; 2) attempt to load values; 3) print them.
This code creates an extra line break after the first but does not print out any of the values that user inputs.
#define NODES 5
typedef struct node
{
int val;
struct node* next;
}
node;
int main(void)
{
node nodes[NODES];
for (int i = 0; i < NODES; i++)
{
printf("Value of node %i: ", i);
nodes[i].val = scanf("%i\n", &nodes[i].val);
}
for (int i = 0; i < NODES; i++)
{
printf("Value of node %i: is %i \n", i, nodes[i].val);
}
return 0;
}