Reverse the order of lines in a text file while preserving the contents of each line: Difference between revisions

Content added Content deleted
(added AWK)
(Reverse the order of lines in a text file while preserving the contents of each line en FreeBASIC)
Line 131: Line 131:
"Diplomacy is the art of
"Diplomacy is the art of
</pre>
</pre>


=={{header|FreeBASIC}}==
<lang freebasic>open "text.txt" for input as #1
dim as string textEnt, textSal()
dim as integer n, linea = 0

do while not eof(1)
line input #1, textEnt
linea += 1
redim preserve textSal(linea)
textSal(linea) = textEnt
loop

for n = ubound(textSal) to 1 step -1
print textSal(n)
next n
close #1
sleep</lang>
{{out}}
<pre>
--- Will Rodgers

until you can find a rock."
saying 'Nice Doggy'
"Diplomacy is the art of
</pre>



=={{header|Go}}==
=={{header|Go}}==