johnny gear Posted January 15, 2010 Share Posted January 15, 2010 the code seems to just ignore the deliminating character and enter the whole first line into the title member of the books struct. I can not figure out why, any help would be appreciated .. thanks while(getline(bookFile,books[count].title,';')) { bookFile>>books[count].year; bookFile.ignore(1); bookFile>>books[count].author; bookFile.ignore(1); bookFile>>books[count].price; count++; } Link to comment Share on other sites More sharing options...
0 Lamp Post Posted January 20, 2010 Share Posted January 20, 2010 the code seems to just ignore the deliminating character and enter the whole first line into the title member of the books struct. I can not figure out why, any help would be appreciated .. thankswhile(getline(bookFile,books[count].title,';')) { bookFile>>books[count].year; bookFile.ignore(1); bookFile>>books[count].author; bookFile.ignore(1); bookFile>>books[count].price; count++; } What is the data type of bookFile and books[count].title? 'cause in getfile, first arguement is the pointer to the c-array where you'll store the string, second arguement is the length of that array, and the third array is the delimiter character... Link to comment Share on other sites More sharing options...
Question
johnny gear
the code seems to just ignore the deliminating character and enter the whole first line into the title member of the books struct. I can not figure out why, any help would be appreciated .. thanks
while(getline(bookFile,books[count].title,';'))
{
bookFile>>books[count].year;
bookFile.ignore(1);
bookFile>>books[count].author;
bookFile.ignore(1);
bookFile>>books[count].price;
count++;
}
Link to comment
Share on other sites
1 answer to this question
Recommended Posts