I just got into structsstructs and iI decided to create a list using them. Here is my code :
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
char counter;
struct list
{
int x;
struct list *pointer1;
struct list *pointer1;
};
struct list test;
struct list *pointer2;
pointer2=&test;
for(counter=0;counter<5;counter++)
{
pointer2->pointer1=malloc(sizeof(struct list));
pointer2=pointer2->pointer1;
}
}`
I was wondering if there is another way to do the exact same thing.Is Is the use of one pointer only possible? By the way i, I am pretty sure iI could do the same thing using an array of structsstructs too.Any Any advice would be really helpful!