I am punching in the shadows with the structure code and got to evolve a bit since the first day (two weeks ago) I saw the word "C basics".
So this does create the structure, stores the data on user input, and prints results. It is in a loop, because say I wanted to store data for different people and I did an array of structures, but of course, this is unpractical. If someone opens the application, he wants to enter as many or as few data as he wants, so the program cannot loop over a predefined number of times. It would have to sort of: Do you want to enter another structure?
It sounds appealing to me, I would be thinking in some dynamic malloc stuff for the structure and maybe some base flag that when Yes, it loops to produce another structure, upon request I mean.
Oh yes, the question actually is: any hint as to how the program should promt for a Structure to be filled upon opening the application ? and once he has finished, the user gets asked if he wants another one.
Here I create 2 instances of the Parent structure, but like I said, this is not something practical. The number of instances needed is unknown, infinite maybe of a million, so creating an array of structures with a predefined number serves no useful purpose. It needs a way it can replicate structures upon request
struct MiEstructura // JUST DEFINING THE STRUCTURE
char * Address;
struct MiEstructura Instancia; // this is an array of structures
struct MiEstructura *ptr;
int main ()
ptr = &Instancia;
for(i=0; i<2; i++)
printf("Enter First Name \n");
printf("Enter Last Name \n");
printf("Enter Address \n");
//LOOPING ALONG THE STRUCTURE INSTANCE TO GET ALL RESULTS
ptr = &Instancia; // Well I thought that I had to reset it so as to point the pointer to the start of the array
for (i=0; i<2; i++)
printf("FirstName %s, LastName %s, Address %s\n", ptr->FirstName, ptr->LastName, ptr->Address);