Write float arrays to a text file: Difference between revisions

no edit summary
No edit summary
Line 1,370:
3 1.7321
1e+011 3.1623e+005
</pre>
 
=={{header|Ring}}==
<lang ring>
# Project : Write float arrays to a text file
# Date : 2018/02/15
# Author : Gal Zsolt (~ CalmoSoft ~)
# Email : <calmosoft@gmail.com>
 
decimals(13)
x = [1, 2, 3, 100000000000]
y = [1, 1.4142135623730, 1.7320508075688, 316227.76601683]
str = list(4)
fn = "C:\Ring\calmosoft\output.txt"
fp = fopen(fn,"wb")
for i = 1 to 4
str[i] = string(x[i]) + " | " + string(y[i]) + windowsnl()
fwrite(fp, str[i])
next
fclose(fp)
fp = fopen("C:\Ring\calmosoft\output.txt","r")
r = ""
while isstring(r)
r = fgetc(fp)
if r = char(10) see nl
else see r ok
end
fclose(fp)
</lang>
Output:
<pre>
1 | 1
2 | 1.4142135623730
3 | 1.7320508075688
100000000000.0000000000000 | 316227.76601683
</pre>
 
2,468

edits