Scanned file looks like that:
Casablanca
1942 D 6.5 4.5 6.0 8.0 7.5
Capernaum
2018 D 5.5 4.5 8.0 8.0 6.5
Stranger Than Paradise
1984 D 6.5 5.5 6.0 8.0 4.5
Three Colors: Red
1994 D 6.5 8.5 6.0 8.0 8.5
Good Bye Lenin!
2003 C 7.5 3.5 6.0 8.0 9.5
Perfume: The Story of a Murderer
2006 D 6.5 5.5 6.0 8.0 5.5
The Shawshank Redemption
1994 D 7.5 5.5 6.0 8.0 8.5
Hacksaw Ridge
2016 D 7.5 7.5 6.0 8.0 7.5
Lost in Translation
2003 D 6.5 4.5 6.0 8.0 7.5
Forrest Gump
1994 D 6.5 9.5 6.0 8.0 6.5
Sleepless in Seattle
1993 R 5.5 4.5 6.0 8.5 7.5
Pride and Prejudice
2005 R 7.5 4.5 7.0 8.0 8.5
I've tried scanning it like this, so basically I want to scan all values from two rows and bind it to their respective places in struct:
while(fscanf(f, "%[^\n]s %d %c %f %f %f %f %f", &filmy[licznik].nazwa, &filmy[licznik].rok, &filmy[licznik].rodzaj, &filmy[licznik].oceny[0], &filmy[licznik].oceny[1], &filmy[licznik].oceny[2], &filmy[licznik].oceny[3], &filmy[licznik].oceny[4]) != EOF)
and when I print it later on using printf()
int i;
for(i = 0; i < N; i++)
{
printf("%s\n%d %c %.1f %.1f %.1f %.1f %.1f\n", filmy[i].nazwa, filmy[i].rok, filmy[i].rodzaj, filmy[i].oceny[0], filmy[i].oceny[1], filmy[i].oceny[2], filmy[i].oceny[3], filmy[i].oceny[4]);
}
instead of getting the output looking exactly as did the input file, I'm getting this:
Casablanca
11801600 0.0 0.0 0.0 0.0 0.0
70 0.0 0.0 0.0 0.0 0.0
F
5 0.0 0.0 0.0 0.0 0.0
P☺┤
0 0.0 0.0 0.0 0.0 0.0
80 0.0 0.0 0.0 0.0 -0.0
Ü2┤
6619204 s 0.0 0.0 0.0 0.0 -0.0
k
7274608 g 0.0 0.0 0.0 0.0 0.0
5 11791315968.0 0.0 0.0 0.0 0.0
0 0.0 0.0 0.0 0.0 0.0
11801176 1834304256.0 0.0 0.0 0.0 0.0
@§@
1322953350 0.0 0.0 0.0 0.0 0.0
►
8 0.0 0.0 0.0 0.0 0.0
Pretty sure that '%[^\n]s' causes the problem, but I have no idea how to scan the title that includes more than one word without using it.