Return to Snippet

Revision: 55467
at February 8, 2012 04:51 by A4i


Updated Code
#include <stdio.h>

struct addressT
{
	char street_name[50];
	int street_number;
	char city[50];
	int zip_code;
};

struct idT
{
	char name[50];
	char surname[50];
	struct addressT addr;
};

struct teleT
{
	char wr_no[50];
	char cell_no[50];
	char fax_no[50];
};

struct emT
{
	char em_work[50];
	char em_home[50];
};

typedef struct
{
	struct idT ident;
	struct teleT tel;
	struct emT email;
} personT;

int main()
{
	personT directory[40];

	int i;

	for(i = 0; i <= 1; i++)
	{
		printf("\nRecord %d: \n", i + 1);

		printf("\n\tName: ");
		scanf("%s", directory[i].ident.name);

		printf("\n\tSurname: ");
		scanf("%s", directory[i].ident.surname);

		printf("\n\tStreet name: ");
		scanf("%s", directory[i].ident.addr.street_name);

		printf("\n\tStreet number: ");
		scanf("%d", &directory[i].ident.addr.street_number);

		printf("\n\tCity: ");
		scanf("%s", directory[i].ident.addr.city);

		printf("\n\tZip code: ");
		scanf("%d", &directory[i].ident.addr.zip_code);

		printf("\n\tTelephone: ");
		scanf("%s", directory[i].tel.wr_no);

		printf("\n\tCell telephone: ");
		scanf("%s", directory[i].tel.cell_no);

		printf("\n\tFax: ");
		scanf("%s", directory[i].tel.fax_no);

		printf("\n\tE-mail (work): ");
		scanf("%s", directory[i].email.em_work);

		printf("\n\tE-mail (home): ");
		scanf("%s", directory[i].email.em_home);
	}

	fflush(stdin);
	getchar();
	return 0;
}

Revision: 55466
at February 8, 2012 04:38 by A4i


Initial Code
#include <stdio.h>

struct addressT
{
	char street_name[50];
	int street_number;
	char city[50];
	int zip_code;
};

struct idT
{
	char name[50];
	char surname[50];
	struct addressT addr;
};

struct teleT
{
	char wr_no[50];
	char cell_no[50];
	char fax_no[50];
};

struct emT
{
	char em_work[50];
	char em_home[50];
};

typedef struct
{
	struct idT ident;
	struct teleT tel;
	struct emT email;
} personT;

int main()
{
	personT directory[40];

	int i;

	for(i = 0; i <= 1; i++)
	{
		printf("\nRecord %d:", i+1);

		printf("\n\tName: ");
		scanf("%s", directory[i].ident.name);

		printf("\n\tSurname: ");
		scanf("%s", directory[i].ident.surname);

		printf("\n\tStreet name: ");
		scanf("%s", directory[i].ident.addr.street_name);

		printf("\n\tStreet number: ");
		scanf("%d", &directory[i].ident.addr.street_number);

		printf("\n\tCity: ");
		scanf("%s", directory[i].ident.addr.city);

		printf("\n\tZip code: ");
		scanf("%d", &directory[i].ident.addr.zip_code);

		printf("\n\tTelephone: ");
		scanf("%s", directory[i].tel.wr_no);

		printf("\n\tCell telephone: ");
		scanf("%s", directory[i].tel.cell_no);

		printf("\n\tFax: ");
		scanf("%s", directory[i].tel.fax_no);

		printf("\n\tE-mail (work): ");
		scanf("%s", directory[i].email.em_work);

		printf("\n\tE-mail (home): ");
		scanf("%s", directory[i].email.em_home);
	}

	fflush(stdin);
	getchar();
	return 0;
}

Initial URL

                                

Initial Description
Η λύση ενός θέματος εξετάσεων... 16/12/11

Initial Title
Προγραμματισμός Ι - Θέμα εξετάσεων 16/12/11

Initial Tags

                                

Initial Language
C