![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Newbie
Join Date: Oct 2007
Posts: 28
Rep Power: 0
![]() |
Re: read integers from file into an array
how do I get it to index where the values are located?
|
|
|
|
|
|
#22 | |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 496
Rep Power: 4
![]() |
Re: read integers from file into an array
Quote:
Don't understand that question. |
|
|
|
|
|
|
#23 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,798
Rep Power: 5
![]() |
Re: read integers from file into an array
Instead of defining min and max as the value, define it as each index. Then refer to the value by indexing the array, and refer to the index as your min/max.
...
if( myArray[i] > myArray[max])
max = i;
else if( myArray[i] < myArray[min])
min = i;
++i;
}
outFile << "The maximum value is " << myArray[max] << " found at array index position " << max << "." << endl; |
|
|
|
|
|
#24 |
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 920
Rep Power: 4
![]() |
Re: read integers from file into an array
Listen to Sane regarding using the index. You don't need to track the maximum value. You only need to track its position within the array, and this allows you to get the value from the array, since you know where it's stored.
Anyways, while other people were replying to you, I whipped up this. It's exactly what you need, but don't just use this for your homework. I'm doing it so you can see how it's done, and I'm only posting code because you've shown you're trying, but if you hand in my work rather than understanding it enough to do it yourself, it'll only hurt you in the long run. c++ Syntax (Toggle Plain Text)
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
|
|
|
|
|
#25 | |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,798
Rep Power: 5
![]() |
Re: read integers from file into an array
Quote:
He'll look to make sure he fully understands it, then echo it into his course's dropbox. But it's not my problem. P.S. Your code tag really glitched out on my side for a second. The wrapping was broken, the font was different, and the background was white. Not sure what that was about. |
|
|
|
|
|
|
#26 | ||
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 920
Rep Power: 4
![]() |
Re: read integers from file into an array
Quote:
I'd rather he ask questions if he doesn't understand, but hey- it's his grade. Quote:
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
||
|
|
|
|
|
#27 |
|
Newbie
Join Date: Oct 2007
Posts: 28
Rep Power: 0
![]() |
Re: read integers from file into an array
thanks for all your comments, yes I want a good grade, and I think I understand the help you've all given me. I will post my new code in a few...please let me know if I've understood all the advice that was given...
thank you all!!!! |
|
|
|
|
|
#28 |
|
Newbie
Join Date: Oct 2007
Posts: 28
Rep Power: 0
![]() |
Re: read integers from file into an array
how do i post a new thread?
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem processing file into a char array | csrocker101 | C++ | 1 | May 8th, 2007 11:50 PM |
| Read and write to one file | nnxion | C | 3 | Apr 11th, 2006 5:10 PM |
| How to read unknown total of int data from text file to a 2-dim array in C | ladyscarlet99 | C | 2 | Sep 9th, 2005 2:28 AM |
| How to read unknown total of int data from text file to a 2-dim array in C++? | ladyscarlet99 | C++ | 2 | Sep 9th, 2005 1:01 AM |
| Installing IPB 2.03 | bh4575 | Other Web Development Languages | 0 | Apr 23rd, 2005 2:36 AM |