• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help reading in file of integers

 
Rick Harding
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to read in a file of integers for a heap sort program. The problem I am having is that the code will only grab the second digit. If the integer is only a single digit it will throw an error on me.



Data File:

10
11
13
19
34
12
45
91
91
16
33


Output:

C:/test.txt
0
1
3
9
4
2
5
1
1
6
3

[ September 28, 2004: Message edited by: Dirk Schreckmann ]
 
chi Lin
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try


[ September 28, 2004: Message edited by: chi Lin ]
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your code is wrong because in every loop you read first character in each line in file.

So, you can change your code like this :

 
Rick Harding
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help everyone!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic