View Single Post
Old 03-03-2005, 08:57 PM   #5 (permalink)
letsC
Registered User
 
Join Date: Mar 2005
Posts: 4
letsC is on a distinguished road
Text file input to an array

I understand most of the code but just have some questions:
QUESTION1:If the input file "in.txt" has variable number of lines (50, 55, any number..) and we don't want to specify the size of array at run time or compile time, What methods could we use? Could we use vectors?

QUESTION2: If the input file has two blocks of data and the code is supposed to stop after reading the first block of data into the array, process it and then read the next block of data into the array. How do we implement that? There is one empty line between the two successive blocks of data.

An example of modified code would help me to understand better.

The input file is as below:
1.854
0x4500004c
0x3728000b
0x7D11FB02
0x81800444
0x81800427
0x4500004c
0x3728000b
0x7D11FB02
0x81800444
0x81800427

2.86
0x4500004c
0x3728000b
0x7D11FB02
0x81800444
0x81800427
0x4500004c
0x3728000b
0x7D11FB02
0x81800444
0x81800427

This discussion is most helpful. I've been banging my head again various sources earlier..I'm glad I came here. Looking forward to your reply!
letsC is offline   Reply With Quote