By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,851 Members | 2,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,851 IT Pros & Developers. It's quick & easy.

Not Bringing In The Next Line HELP!!

P: 21
So my code is below. I have a problem... I am trying to bring in a text file that is like this:
Principles of Biochemistry
Biology
Chemistry
$
Introductory Organic Chemistry
Chemistry
$

I get the first book and its two keywords and the $ but when i exit the inner loop and go to the outer loop i am needing to bring in "Introductory Organic Chemistry", But the inner loop doesn't get it to the next line so I read in ""...
What am I forgetting????

Expand|Select|Wrap|Line Numbers
  1. for(int i = 0; i < MAXBOOKS; i++)
  2.         {
  3.             infile.getline(theBook[i].title, MAXLENGTH);
  4.             for(int j = 0; j < MAXKEYWORDS; j++)
  5.             {
  6.                 char trashWord[MAXKEYWORDS][MAXLENGTH];
  7.                 char trash;
  8.                       infile >> trashWord[j];
  9.                 if(strcmp(trashWord[j], "$") != 0)
  10.                 {
  11.                     strcpy(theBook[i].keyWord[j], trashWord[j]);
  12.                     theBook[i].numberOfKeyWords = j+1;
  13.                 }
  14.                 else
  15.                 {
  16.                     j = MAXKEYWORDS;
  17.                 }
  18.             }
  19.  
  20.             cont = false;
  21.         }
  22.  
Sep 26 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.