Say I run a program which makes several printf statements over the course of its running. Naturally every time it hits a printf command it will print. How would I go about instead of printing it, "store" it, and then at the end of the program, take all the lines that should have been printed, sort it AND THEN print it.
e.g.
Run Program
prints "File1 90"
prints "File2 30"
prints "File3 40"
End Program
Run Program
prints "File1 90" (don't actually print it out)
prints "File2 30" (don't actually print it out)
prints "File3 40" (don't actually print it out)
Take print statements and rearrange them by numerical order, then print
Program prints:
prints "File2 30"
prints "File3 40"
prints "File1 90"
I think I have to use a unix shell command within my C program such as
sort -k2n,2 -k1,1 myprogram
sort
? – templatetypedefmyProgram arg1 file [file ...n] | sort
. Good luck. – shellter