There are 2 fundamental ways to deal with this.
Pass data between functions
You could turn your programs into individual functions, and you could pass data between these functions. Whatever Function 1 returns (make it return outpu as data, instead of printing it on the screen) should be consumed as a parameter by Function 2.
I do not know Ruby, but you can look at this tutorial to learn about functions.
In C, the code would look something like this.
#include <stdio.h>
char * Function1()
{
char * data = NULL/* produce your data, instead of NULL */;
return data;
}
void Function2(const char * data)
{
// Do someting with data
}
int main()
{
char * dataFromFunction1 = Function1();
Function2(dataFromFunction1);
return 0;
}Pass data between programs
You can keep your individual programs and connect them together. This assumes a Program1 writes the standard output while Program2 reads the standard input.
Then, in a command shell you could invoke Program1 and pipe its output to Program2. It would look something like this:
Program1 | Program2
This needs you to run your command in a shell. If you use the OnlineGDB, then you can save the output as a file instead in Program1 and read from a file in Program2