![]() |
|
#1
|
||||
|
||||
Array problem @@Hi,
This is my 15th homework and I am still quite new to C++. I have written this code but i cant find the mistake... -------------------------------------------------------------------------- CPP / C++ / C Code:
Here are the error -------------------------------------------------------------------------- CPP / C++ / C Code:
__________________
just started to learn C++ :) |
||||
|
#2
|
||||
|
||||
Re: Array problem @@Well i found my mistake at "setw[10]"
after i correct it...the prgoram still couldnt work even there is no error @@ __________________
just started to learn C++ :) |
|
#3
|
|||
|
|||
Re: Array problem @@Quote:
CPP / C++ / C Code:
EDIT Okay, that was a lame joke. In your loop you increase the value of i by one each time. So what is the value of i when you finally get to the test in your loop? Is it as it should be, is it one less than it should be or is it one more than it should be? Also, you test for the value -999. This is probably used to signal the end of the file? It seems like a poor practise. More recommended would be to use ifstream::eof(). Just remember it is true not until you have tried to actually read past the end. Last edited by Kimmo : 09-Nov-2009 at 01:44.
|
|
#4
|
||||
|
||||
Re: Array problem @@Well...after i try to execute the code..it just stop working and leave " Press anykey to continue..."
__________________
just started to learn C++ :) |
|
#5
|
|||
|
|||
Re: Array problem @@Quote:
What IDE are u using? Did you try step through using debug mode? If you aren't using IDE, try printing out those values to screen to see any if those values make any sense. From your code, i think it should at least print something. Did some dialog box pop up and say an error occur? ITS BEST YOU TRY STEPPING THROUGH IN DEBUG MODE. CPP / C++ / C Code:
Attach to this post, i'll try to see "if i have time"... hehe. But this loop is a big problem. Hope this helps!!! Jeremy |
|
#6
|
||||
|
||||
Re: Array problem @@First arrays are zero indexed.
Quote:
if you have n elemnts then array access is: CPP / C++ / C Code:
Quote:
Quote:
Quote:
CPP / C++ / C Code:
|
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pointer to array of pointers to objects problem | icedown | C++ Forum | 1 | 06-Oct-2009 22:35 |
| where is the problem and can you fix it (php) | oggie | MySQL / PHP Forum | 8 | 14-Apr-2008 15:08 |
| Getting a line error in register | oggie | MySQL / PHP Forum | 5 | 13-Apr-2008 16:16 |
| Returning a 2 dimensional Array from a function | vicky_brsh | C++ Forum | 1 | 04-Jan-2008 14:06 |
| Need help deleting the last element in the array | headphone69 | C++ Forum | 2 | 15-Mar-2006 19:31 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The