View unanswered posts | View active topics It is currently Thu Mar 28, 2024 12:36 pm



This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
coding help? 
Author Message
Champion
User avatar

Joined: Mon Oct 25, 2010 10:22 am
Posts: 107
Location: California
Post coding help?
I have this code that builds correctly...what I can't figure out to the life of me is that when it comes to this loop it keeps giving me an out of range error...I'd appreciate if anyone could help. -.-

Code:
cout << "Pick a number." << endl;
cin >> choice;
bool numberWasFound = false;

int j;

for (j = 0; sortedCollection.size(); j++)
{
   if(sortedCollection[j] == choice)
   {
      numberWasFound = true;
   }      
}   
   
if(numberWasFound == true)
{
   cout << "At index: " << j << endl;
}
else if (numberWasFound == false)
{
   cout << "Not found" << endl;
}

_________________
I tend to generally dislike people. :)


GC#s
Main accounts:
42001670
-Emma Mae
-Molly V1.1
-Emily Rose
-Inara

42001690
-Cain
-Abel
-Archomito
-Starr

42001691
-Mustang
-Lt. Havoc
-LtHawkeye
-Anthrax


Fri May 06, 2011 11:48 pm
Profile YIM
Champion
User avatar

Joined: Mon Oct 25, 2010 10:22 am
Posts: 107
Location: California
Post Re: coding help?
Erm...I found it and feel like a complete idiot for not noticing it...-.-

Sorry for double posting...

_________________
I tend to generally dislike people. :)


GC#s
Main accounts:
42001670
-Emma Mae
-Molly V1.1
-Emily Rose
-Inara

42001690
-Cain
-Abel
-Archomito
-Starr

42001691
-Mustang
-Lt. Havoc
-LtHawkeye
-Anthrax


Sat May 07, 2011 12:31 am
Profile YIM
extended rech
User avatar

Joined: Mon Dec 07, 2009 3:10 pm
Posts: 1264
Location: Danbooru
Post Re: coding help?
And less than an hour afterwards, too! XD

_________________
o says (15:58):
*I've been tempted to ban a few people in the past simply because I found them annoying.
"Reason for ban: Because I can't punch you in the face."

Image

Give a girl the right shoes and she will conquer the world.


Sat May 07, 2011 10:08 pm
Profile
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 39 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.