- Przy wczytywaniu danych, jeśli w polu 'title' wpiszę słowa oddzielone spacją, to te po spacji są wczytywane do następnego pola. Jak zrobić, żeby można było w pole 'title' i w pozostałych wpisać choćby dwa wyrazy oddzielone spacją?
- Jak powinna wyglądać funkcja wyszukująca po tytule?
#include <stdio.h>
#include <ctype.h>
#include <string.h>
struct book {
char title[50];
char genre[50];
char aname[50];
int year;
};
int main ()
{
struct book library[10];
int c=1;
int i=0;
for (c=1, i=0; c<11; i++, c++)
{
printf("Type title of the %d book\n",c);
scanf("%s", &library[i].title);
printf("Type genre of the %d book\n",c);
scanf("%s", &library[i].genre);
printf("Type author's name of the %d book\n",c);
scanf("%s", &library[i].aname);
printf("Type the year of publishing of the %d book\n",c);
scanf("%d", &library[i].year);
}
printf("\nThis is your library:");
for(i=0;i<10;i++)
{
printf("Title\tGenre\tAuthor's name\tYear of publishing\n");
printf("%s, %20s, %20s, %20d", library[i].title, library[i].genre, library[i].aname, library[i].year);
}
return 0;
}