Computing.Net > Forums > Programming > array input problem in c++

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

array input problem in c++

Reply to Message Icon

Name: one1082
Date: November 7, 2003 at 10:58:55 Pacific
OS: win xp
CPU/Ram: p3 700
Comment:

I'm kicking myself because this isn't working. Basically, I need to read a bunch of numbers from an input file to an array and sort them. My problem is, I'm supposed to stop at the end of the line, sort that array, then read another line, sort that, and so on. I'm having trouble getting the loop to stop inputing at the end of the line. Using chars, I can get it to recognize the end of line character ('\n'), but using integers this doesn't work. Any ideas?



Sponsored Link
Ads by Google

Response Number 1
Name: borelli35
Date: November 7, 2003 at 12:44:26 Pacific
Reply:

With those kind of specifications it almost sounds like a homework assignment. Post the code you have written in your attempts so that we can see what you have done and specify where it is that you are currently stuck at.

borelli35


0

Response Number 2
Name: Ronin1
Date: November 8, 2003 at 09:57:24 Pacific
Reply:

What sort of loop are you using? Something like this *should* work. ch is an integer.

while((ch=inFile.peek()) != EOF)
{
inFile >> temp;

if(ch == '\n')
mysort(myarr, index);

myarr[index++] = temp;
}


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Javascripting help! Private java



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: array input problem in c++

problem in c www.computing.net/answers/programming/problem-in-c/12469.html

an array of strings in C www.computing.net/answers/programming/an-array-of-strings-in-c/7230.html

Problem in 'C'. www.computing.net/answers/programming/problem-in-c/2089.html