Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Reading from .txt and putting data (double) in array[]
Reading from .txt and putting data (double) in array[] [message #47654] Tue, 21 February 2017 21:36 Go to next message
Diego22 is currently offline  Diego22
Messages: 10
Registered: November 2016
Location: Zaragoza
Promising Member
Hi,

I need to read a .txt already created and fill a array with the numbers of the indicated lines.
File starts with words and other numbers, so I want to read from 7th line to 19th, then put these 12 numbers (double) in a int array[].

I've been trying for a long time but I have not been able to. Let's see if someone can help me.

Regards.

[Updated on: Wed, 22 February 2017 01:02]

Report message to a moderator

Re: Reading from .txt and putting data (double) in array[] [message #47657 is a reply to message #47654] Wed, 22 February 2017 12:45 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
hi,

here a possibe solution
FileIn fi("c:\\tmp\\f.txt");
int array[12];

for(int i = 0; i< 6 && !fi.IsEof(); i++)
{
  String line = fi.GetLine();
}

for(int i = 0; i< 12 && !fi.IsEof(); i++)
{
  String line = fi.GetLine();
  double d = StrDbl(line);
  array[i] = (int)d;
}



regards
omari.
Re: Reading from .txt and putting data (double) in array[] [message #47659 is a reply to message #47657] Wed, 22 February 2017 13:16 Go to previous message
Diego22 is currently offline  Diego22
Messages: 10
Registered: November 2016
Location: Zaragoza
Promising Member
Thank you very much omari!

Code is shorter than I was trying. With this I'll be able to advance in my thesis.

Thank you again and regards.
Previous Topic: Connect with an external static library
Next Topic: [SOLVED] How to load an array added to an TabCtrl?
Goto Forum:
  


Current Time: Thu Mar 28 22:03:18 CET 2024

Total time taken to generate the page: 0.02316 seconds