Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define N 5
- struct adres {
- char* city;
- char* street;
- int house;
- };
- void viewer (struct adres *);
- void cout (struct adres *);
- int main () {
- struct adres a[N]= {
- "Novosibirsc", "Lenina", 10,
- "Irkutsk", "Michurina", 30 ,
- "Sanct-Peterburg", "Rechnaya", 20 ,
- "Moscov", "Lenino", 2 ,
- "Chita", "Kutuzova", 1
- };
- viewer(a);
- cout(a);
- }
- void viewer (struct adres *a) {
- int i;
- for (i=0; i < N; i++, a++)
- printf("%2d) city:%12s, street:%10s, house:%3d\n", i+1, a->city, a->street, a->house);
- }
- void cout (struct adres *a) {
- char c[15];
- int i;
- printf("enter a city: ");
- gets(c);
- for (i=0; i < N; i++)
- if (strcmp((a+i)->city,c)==0)
- printf("city:%12s\nstreet:%10s\nhouse:%3d\n", (a+i)->city, (a+i)->street, (a+i)->house);
- }
Add Comment
Please, Sign In to add comment