473,382 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

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
1 1190
weaknessforcats
9,208 Expert Mod 8TB
list<int>::iterator currentIt is a local variable in the if statement. It goes out of scope when you leave the if statement.

If you need it outside the if statement, then define it outside the if statement.
Oct 27 '10 #2

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

Similar topics

28
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a...
0
by: William Ryan | last post by:
I hate using Dynamic SQL and was prohibited from doing so b/c we couldn't use 'IN' Statement in the where clause with Parameters which broke out data access block. I wrote a work around which...
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
2
by: terpatwork | last post by:
Hi, (1) I have an access form that allows users to enter data, and when they click a button, the OnClick code that I've written uses a SQL INSERT statement to insert the data into the database. I...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
18
by: Scott David Daniels | last post by:
There has been a bit of discussion about a way of providing test cases in a test suite that _should_ work but don't. One of the rules has been the test suite should be runnable and silent at every...
7
by: Thomas Nelson | last post by:
Occasionally someone posts to this group complaining about the lack of "repeat ... until" in python. I too have occasionally wished for such a construct, and after some thinking, I came up with...
1
by: BizWorld | last post by:
I am using .NET 2.0 new classed for FTP download purpose. I have requirement to connect with 3 different FTP and download all files list and see if file exist at my end. if not then i need to...
2
by: GarryJones | last post by:
(I am sorry if this is the wrong group for this posting, I cant find a group on usenet for phpmyadmin, but maybe someone would be nice enough to answer me anyway....) I need to import data into...
6
by: knellim | last post by:
Hello All, I am using PHP to connect to derby/db2 database. I want to implement unix_timestamp() function (used in mysql) to its equivalent in derby database. I found the equivalent as select {fn...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.