Hmm.. I have a problem. I should find and output to screen all records with people who live in city -Riga(for example). This doesn't work :-D
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <windows.h>
#define N 10
int main()
{
struct people
{
char city[20], name[15];
} people[25];
int i, j;
system("cls");
printf("Complete the list:\n");
for(i=0; i<N; i++)
{
printf("Name: ");
gets(people.name);
printf("City: ");
gets(people.city);
}
system("cls");
printf("List\n");
for(i=0; i<N; i++)
printf("\n%20s%15s", people.city, people.name);
printf("\n");
printf("\n\nList with people who live in Riga:");
for(i=0; i<N; i++)
if(people.city=="Riga")
printf("\n%20s%15s", people.city, people.name);
getch();
return 0;
}
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <windows.h>
#define N 10
int main()
{
struct people
{
char city[20], name[15];
} people[25];
int i, j;
system("cls");
printf("Complete the list:\n");
for(i=0; i<N; i++)
{
printf("Name: ");
gets(people.name);
printf("City: ");
gets(people.city);
}
system("cls");
printf("List\n");
for(i=0; i<N; i++)
printf("\n%20s%15s", people.city, people.name);
printf("\n");
printf("\n\nList with people who live in Riga:");
for(i=0; i<N; i++)
if(people.city=="Riga")
printf("\n%20s%15s", people.city, people.name);
getch();
return 0;
}