-2

Possible Duplicate:
Read data from a file individually and multiply the two columns in C++

Hi all I have a sequence of data files[1.dat,2.dat,3.dat ........200.dat] each including 4 columns and 250 rows. I need to read each data and process them such as multiply the second column of each file. May you suggest me the way how I can do this please? I have to use C++ for coding. Thanks. ND

Community
  • 1
  • 1
nagendra
  • 245
  • 6
  • 13
  • Could you please provide some information about the file characteristics, e.g. is it binary data and if what sizes etc. Do you want to read them fully and combine them in memory? I see an impending "homework" tag anyway ;) – Jules Mar 01 '11 at 16:04
  • The questino is not clear. What do you mean saying "I need to read each data and process them such as multiply the second column of each file"? – Mihran Hovsepyan Mar 01 '11 at 16:05
  • @nagendra It seems like you asked this question already (http://stackoverflow.com/questions/5156597/read-data-from-a-file-individually-and-multiply-the-two-columns-in-c). This should be closed as a dupe (modify the original question). – Lou Mar 01 '11 at 16:06
  • @badgerr Sounds like it to me. – Lou Mar 01 '11 at 16:07
  • Retagged as homework, assuming it doesn't get voted for close. – badgerr Mar 01 '11 at 16:10

1 Answers1

2

You will have to read in the contents of every file into arrays. Next process the array content.

Shamim Hafiz - MSFT
  • 21,454
  • 43
  • 116
  • 176
  • 1
    Are you serious? You just slightly changed the numbers, it could still be considered a duplicate. You will have to read the file (binary or as text), store it in memory, e.g. arrays or, easier, higher level collections like map and then write it back. If that doesn't help you at all, please read a bit and start coding! You could start here: http://www.cplusplus.com – Jules Mar 01 '11 at 16:44
  • @Jules: Was the comment directed to me?? – Shamim Hafiz - MSFT Mar 02 '11 at 05:38
  • 1
    Nope, it was directed at OP, but he deleted his comment. Should've addressed him. – Jules Mar 02 '11 at 08:58