Well, I'm working with structures arrays, and I'm trying to input a value for one of that arrays.
This is my code so far:
#include<stdio.h>
struct client
{
char Name[50];
char Sex;
int Age;
float Weight;
float Height;
int Borning[3];
char Phone[15];
};
int main()
{
int o = 1;
struct client AAA[o];
printf("\n---Client %i---\n", o);
printf("Imput the name of the client:\n");
scanf(" %50[^\n]", AAA[o-1].Name);
printf("Input the sex of the client:\n");
scanf("%c", AAA[o-1].Sex);
printf("Input the age of the client:\n");
scanf("%i", AAA[o-1].Age);
printf("Input the weight of the client:\n");
scanf("%f", AAA[o-1].Weight);
printf("Input the height of the client:\n");
scanf("%f", AAA[o-1].Height);
printf("Input the date of birth of the client.\n");
printf("Day:\n");
scanf("%i", AAA[o-1].Borning[0]);
printf("Month:\n");
scanf("%i", AAA[o-1].Borning[1]);
printf("Year:\n");
scanf("%i", AAA[o-1].Borning[2]);
printf("Input the phone of the client:\n");
scanf(" %20[^\n]", AAA[o-1].Phone);
printf("\nCLIENT SUCCESFULLY AGGREGATED\n");
}
When I run it, it does the printf("Imput the name of the client:\n");
line, and it allows the user to input the valor for AAA[o-1].Name
. But then, it does the printf("Input the sex of the client:\n");
line and suddenly skips the rests of lines, returning what seems to be a memory location.
I want it to let the user input all the values and fill the empty variables in that specific array.
Sorry for any typo. Also, take in consideration I'm pretty new with C. I'm using codeblocks. Thank you in advance. ;)