Why does vector get out of range?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 26
Reputation: Arne Kristoffer is an unknown quantity at this point 
Solved Threads: 1
Arne Kristoffer's Avatar
Arne Kristoffer Arne Kristoffer is offline Offline
Light Poster

Re: Why does vector get out of range?

 
0
  #11
Apr 16th, 2008
Well, the MyFile-object has so many details in it, so I can't see if it's opened, but this is the MyFile line in watch:

Originally Posted by watch
+ MyFile {_Filebuffer={...} } std::basic_fstream<char,std::char_traits<char> >
Since the program is located in "C:\Users\Arne\Documents\Visual Studio 2008\Projects\Bank_project\Debug", wouldn't "..\\..\\..\\..\\..\\..\\..\\data.dat" be C:\file.dat? (For example?)

I could try locating the file another place.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 26
Reputation: Arne Kristoffer is an unknown quantity at this point 
Solved Threads: 1
Arne Kristoffer's Avatar
Arne Kristoffer Arne Kristoffer is offline Offline
Light Poster

Re: Why does vector get out of range?

 
0
  #12
Apr 16th, 2008
This is bloody creepy!

I moved the file to \\..\\..\\..\\..\\..\\..\\..\\data

It worked. And, you were right, it stops at the erase-loop.

The reason why it stopped, was that i tried to remove "(" and ")" from "", which logically won't happen. So I added
  1. if (!vec[x].empty())
, so that it wouldn't try to delete "(" and ")" where it doesn't exist.

But, by the way, do you know why I have to locate the file somewhere else?

Thank You!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,401
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1467
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Why does vector get out of range?

 
0
  #13
Apr 16th, 2008
>>But, by the way, do you know why I have to locate the file somewhere else?

The file must be in the same folder that your program is running in unless the open statement tells it otherwise. For example
ifstream in("c:\\myfolder\\temp.txt");
Last edited by Ancient Dragon; Apr 16th, 2008 at 11:04 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC