Printing to a file problem ... embarssing
Author |
Message |
Kuntzy
|
Posted: Mon Feb 02, 2004 10:23 pm Post subject: Printing to a file problem ... embarssing |
|
|
just look at this code, and when you open up the text file, all of the lines are running continueously after one another? what have i forgotten?
Description: |
|
Download |
Filename: |
factors.t |
Filesize: |
302 Bytes |
Downloaded: |
266 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Kuntzy
|
Posted: Mon Feb 02, 2004 10:24 pm Post subject: (No subject) |
|
|
don;t post anything about how stupid i am, i feel stupd enough for even asking this
|
|
|
|
|
|
Paul
|
Posted: Mon Feb 02, 2004 10:27 pm Post subject: (No subject) |
|
|
What do you mean? It looks fine to me if your trying to find prime numbers from 2 to 150, though you don't show the prime number factors.
|
|
|
|
|
|
santabruzer
|
Posted: Mon Feb 02, 2004 10:38 pm Post subject: (No subject) |
|
|
well .. you just gotta do this or something of the sort :
code: | var fil : int
open : fil, "Factors.txt", put
for i : 2 .. 150
put : fil, chr (10), "Factors of ", i, ": " ..
put "Factors of ", i, ": " ..
for j : 2 .. i - 1
if i mod j = 0 then
put : fil, j, " " ..
put j, " " ..
end if
end for
put ""
end for
close (fil)
|
As you can see..
code: | put : fil, chr (10), "Factors of ", i, ": " .. |
is added, and the chr (10) basically is the "enter" in the txt file...
|
|
|
|
|
|
Kuntzy
|
Posted: Tue Feb 03, 2004 8:34 pm Post subject: (No subject) |
|
|
yeah, thanx for the help, the code was fine except for writing to the file, i couldn't get the line to skip down on the text file.
|
|
|
|
|
|
Mazer
|
Posted: Wed Feb 04, 2004 2:32 pm Post subject: (No subject) |
|
|
Hey Kuntzy,
just replace the
after your for loop with
Or, if you want the output on the screen to be properly formatted, then add the previous line instead of using it to replace that first one.
|
|
|
|
|
|
|
|