Raised This Month: $ Target: $400
 0% 

diffrent origins from a file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
stupok
Veteran Member
Join Date: Feb 2006
Old 02-21-2009 , 18:54   Re: diffrent origins from a file
Reply With Quote #8

Like this:

yourfile.txt:
Code:
0 0 0
185.564 5461.4 1.111
12 16 86.5
Code:
#define FILE "yourfile.txt" public do_stuff() {     // open file in R ead T ext mode, assign handle     new fh = fopen(FILE, "rt")         // failed to open     if(!fh) return         new szBuffer[64]     new szOrigin1[16]     new szOrigin2[16]     new szOrigin3[16]     new Float:fOrigin[3]         // keep going until end of file     while(!feof(fh))     {         // read a line into szBuffer         fgets(fh, szBuffer, charsmax(szBuffer))                 // split szBuffer into 3 parts         parse(szBuffer, szOrigin1, charsmax(szOrigin1), szOrigin2, charsmax(szOrigin2), szOrigin3, charsmax(szOrigin3))                 // convert string to float         fOrigin[0] = str_to_float(szOrigin1)         fOrigin[1] = str_to_float(szOrigin2)         fOrigin[2] = str_to_float(szOrigin3)                 // do something with the origin         // ...     }         // always close if you open     fclose(fh) }
__________________
stupok is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode