944,078 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 3589
  • C RSS
Oct 24th, 2007
0

converting string[][] to float[]

Expand Post »
I am trying to convert some data that I read in file as string data to a float array

The data that is read are in two dimensional string array like
  1. char tmatrix[10][100];
  2. for(j=0;j<k3;j++){printf("\n %s",tmatrix[j]);} //k3=max data read
  3. 0.5
  4. 0.2
  5. 0.3
  6. 0.6

Now I need to convert the content of tmatrix[][] into a float array
so that float_array[1]=0.5
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
mank is offline Offline
41 posts
since Oct 2007
Oct 24th, 2007
-1

Re: converting string[][] to float[]

No problem -- just call atof()
  1. float n = atof(tmatrix[i]);

Not a perfrect solution, but works ok for most purposes.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,957 posts
since Aug 2005
Oct 24th, 2007
0

Re: converting string[][] to float[]

Thanks a lot
Reputation Points: 10
Solved Threads: 0
Light Poster
mank is offline Offline
41 posts
since Oct 2007
Oct 25th, 2007
1

Re: converting string[][] to float[]

strtod() would be a better function to use, because it has better error diagnostics.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Yet another ATM post (split from the dead)
Next Thread in C Forum Timeline: double and float......





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC