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

can I get some feedback on why this IF statement is failing me?

P: 5
I cant seem to find the problem in this code...

Expand|Select|Wrap|Line Numbers
  1. ifstream fin;
  2.     fin.open("C:/Users/Josh/Desktop/TriNode/NumList.txt");
  3.  
  4.     int first;
  5.     fin >> first;
  6.  
  7.     cout << first;
  8.  
  9.     if(first < 10)
  10.     {
  11.         trinode root(first);
  12.         list<int>::iterator currentIt;
  13.  
  14.         while(!fin.eof())
  15.         {
  16.             int temp;
  17.             fin >> temp;
  18.             root.insert_node(temp);
  19.         }
  20.     }
  21.  
when I try to use the trinode "root" or the iterator "currentIt" after this if statement, it keeps giving me errors saying they are not declared, which I would assume means it never gets past the IF(first <10) but If i cout << first right before, its 8.....which is obviously less than 10. If i remove the if statement it will work..but i NEED that statement for later code.
Oct 27 '10 #1
Share this Question
Share on Google+
2 Replies


P: 5
I just commented out the inside of the IF and replaced it with a cout << "This works"; and for some reason THAT will work, but it wont work when I use the code above...
Oct 27 '10 #2

P: 5
alright that was a stupid mistake...nevermind
Oct 27 '10 #3

Post your reply

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