• 0

File input - getline / deliminating character issues


Question

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

  • 0
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++;

}

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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.