*Sigh*, i have no idea why the while() part below doesn't work
(only always the first set was being read) (1, The C++ Programming Lang, Bjarne Stroustrup)
This is what the file looks like :
1
The C++ Programming Language
Bjarne Stroustrup
2
The C Programming Language
Brian Kerninghan, Dennis Ritchie
3
Head First Java
Oreilly Media
// ...
static Book book[ MAX_BOOKS ]; // I know i should have use std::vector
size_t tempBookId;
char tempTitle [ MAX_CHAR ]; // yeah, i know i should have use std::string
char tempAuthor[ MAX_CHAR ];
size_t i = 0;
// This loop isn't working : (i have no idea why)
while( fileIn >> tempBookId &&
fileIn.ignore() &&
fileIn.getline( tempTitle, MAX_CHAR ) &&
fileIn.getline( tempAuthor, MAX_CHAR ) )
{
book[ i ].bookId = tempBookId;
strncpy( book[ i ].title,
tempTitle,
MAX_CHAR );
strncpy( book[ i ].author,
tempAuthor,
MAX_CHAR );
i++;
}
// ...
return book;