Hello
well, I am trying to build a structure, on a self learning purpose, and while I know other primitive ways of filling the structures, I want it this way. Actually that the user is prompted to enter himself and then it prints as it goes along. However, it does nothing after the scanf.
Of course, the code needs to be more evolved, so that we can get to fill as many structures as we want, such as putting them in a loop and asking the user how many he wants offered etc and also when to call it off, but so far I need to get the grasps of this.
Code:
#include <stdio.h>
#include <stdlib.h>
struct MiEstructura // JUST DEFINING THE STRUCTURE
{
char FirstName[20];
char LastName[30];
char * Address[50]; // THIS WOULD ACTUALLY BE AN ARRAY OF 50 POINTERS TO TYPE CHAR, NOT CORRECT THEN...
int MyAge;
};
struct MiEstructura Instancia[2]; // NOW 2 INSTANCES OF IT
struct MiEstructura *ptr;
int main ()
{
int i;
ptr = &Instancia[0];
printf("Enter First Name \n");// nothing happens after I enter a name
scanf("%s\n",ptr->FirstName);
printf("%s\n",ptr->FirstName);
printf("Enter Last Name \n");
scanf("%s\n",ptr->LastName);
printf("%s\n",ptr->LastName);
printf("Enter Address \n");
scanf("%s\n",ptr->Address);
printf("%s\n",ptr->Address);
getchar();
return 0;
}