V
Vasu
Hi! Can anybody there help me in analysis of the following code, which
is a structure of customer's details, asks user to fill in the no. of
customers and then their details. When I put in no. of customer as 2
and start filling in users details, in the detail of second customer
till the name of State is OK as soon as I fill in the detail of State
and press enter, it shows the field of PIN code but then suddenly it
says something like "Encountered an error application needs to be
closed......", I use digimars C Compiler to compile the application
and I run the compiler on top of DOS shell of Windows XP. Code goes
right here :
/*Definition of Structure*/
/*Struct.C*/
#include<stdio.h>
/*Structure declaration for address*/
struct Addr
{
char Street[30];
char City[30];
char State[20];
int Pin[5];
};
/*Nested Structure for Customer's Info*/
struct Customer
{
char Name[20];
char Account_No[6];
struct Addr Address;
};
/*Now main fuction starts */
void main()
{
struct Customer *List[100];
int i, n;
printf("\n Input number of records you want to process: ");
scanf("%d", &n);
fflush(stdin);
/*Asking to fill in the customer' info*/
printf("\n Input the information of customer \n");
for(i=0; i<n; i++)
{
printf("\n Name: ");
gets(List->Name);
printf("\n Account No.: ");
gets(List->Account_No);
printf("\n *****Address*****\n");
printf("\n Street: ");
gets(List->Address.Street);
printf("\n City: ");
gets(List->Address.City);
printf("\n State: ");
gets(List->Address.State);
printf("\n Pin Code: ");
scanf("%d", &List->Address.Pin);
fflush(stdin);
}
printf("\n List of the customer \n");
printf("8888888888888888888888888\n");
for(i=0; i<n; i++)
{
printf("\n Name: %s", List->Name);
printf("\n Account No.: %s", List->Account_No);
printf("\n *****Address***** \n");
printf("\n Street: %s", List->Address.Street);
printf("\n City: %s", List->Address.City);
printf("\n State: %s", List->Address.State);
printf("\n Pin Code: %d", List->Address.Pin);
}
}
Thanking you in advance.
Regards,
Vasu
is a structure of customer's details, asks user to fill in the no. of
customers and then their details. When I put in no. of customer as 2
and start filling in users details, in the detail of second customer
till the name of State is OK as soon as I fill in the detail of State
and press enter, it shows the field of PIN code but then suddenly it
says something like "Encountered an error application needs to be
closed......", I use digimars C Compiler to compile the application
and I run the compiler on top of DOS shell of Windows XP. Code goes
right here :
/*Definition of Structure*/
/*Struct.C*/
#include<stdio.h>
/*Structure declaration for address*/
struct Addr
{
char Street[30];
char City[30];
char State[20];
int Pin[5];
};
/*Nested Structure for Customer's Info*/
struct Customer
{
char Name[20];
char Account_No[6];
struct Addr Address;
};
/*Now main fuction starts */
void main()
{
struct Customer *List[100];
int i, n;
printf("\n Input number of records you want to process: ");
scanf("%d", &n);
fflush(stdin);
/*Asking to fill in the customer' info*/
printf("\n Input the information of customer \n");
for(i=0; i<n; i++)
{
printf("\n Name: ");
gets(List->Name);
printf("\n Account No.: ");
gets(List->Account_No);
printf("\n *****Address*****\n");
printf("\n Street: ");
gets(List->Address.Street);
printf("\n City: ");
gets(List->Address.City);
printf("\n State: ");
gets(List->Address.State);
printf("\n Pin Code: ");
scanf("%d", &List->Address.Pin);
fflush(stdin);
}
printf("\n List of the customer \n");
printf("8888888888888888888888888\n");
for(i=0; i<n; i++)
{
printf("\n Name: %s", List->Name);
printf("\n Account No.: %s", List->Account_No);
printf("\n *****Address***** \n");
printf("\n Street: %s", List->Address.Street);
printf("\n City: %s", List->Address.City);
printf("\n State: %s", List->Address.State);
printf("\n Pin Code: %d", List->Address.Pin);
}
}
Thanking you in advance.
Regards,
Vasu