Read printed output into array (3.3 main)


how can I access data that has been printed? I’d like to put it into an array :slight_smile:

I don’t quite understand the question.

If you want to look at printed data (maybe automatically), you can pipe the output stream to a file as described here:

If you want to access previously printed data in C,
you could redirect the output stream.
But in general, this is not a good idea for efficiency reasons.
And it is more complicated than it needs to be.
Generally, you should represent the data in a better manageable form/data structure and use the data in different places to
a) print it
b) do further computations

Ok, thank you… maybe I’m just a bit confused right now :smiley:

Well, to help alleviate your confusion…

Why do you want to do this? What is your end goal?? (Try avoiding the


I wanted to use the find_print_min_path function to get seam for find_and_carve_path but now I just use the functions of energy.c from 3.2 …

Indeed, this is how you are supposed to solve this.

In general, it often happens during programming that you notice that some functionality is used multiple times in a program (here, it was finding a seam). In that case, it can make sense to generalize your program and move that functionality to a dedicated method. Here, this method is already given, namely calculate_optimal_path.