Passing in Array output into Main from different files

My problem:
I need to create an array of 4,294,967,296 entries (max un-signed int) based off of file content and have many many other files run off of this array data.

I see two solutions:
1.) Rebuild the array every time (every index only contains a 1 bit number as a value, so building it is relatively "fast")
2.) Feed in the output array from one file into every new program that needs to use it.

My Predicament:
I don't know an efficient way to feed an outputted array from a program into another one (let alone how to return an array from main).

I'm doing this all from a linux command line and will be running the finalized version in a BASH script, so anyone who has experience or suggestions would be much appreciated. Cheers
Decided to change my file structure, so all the files I need to run off of the array data could be passed in at once. For that reason now I can implement it all into one program, so problem solved I suppose.
Code: Hello
1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;
int main()
{
	for(int i = 0; i < 300; i ++)
	{
		cout << "hi" << i << " ";
	}
}


Code: Bounceback
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string bigLine;
	getline(cin, bigLine);
	
	cout << bigLine.substr(222, 100);
}



Compile both files and then pipe the first into the second in terminal:
./Hello | ./Bounceback

This sends all cout output from Hello as cin input to Bounceback, Bounceback does some manipulation on that data then outputs the new version, but this time it is not grabbed by another pipe so it's output to the user..


You're right, solving it all from within one program is the fastest way, but I figured I should post an answer for your original question in case hypothetically you don't have access to the code of the first program.
This version is much faster than saving the output of Hello to file then accessing that file in Bounce because piping keeps all the information in RAM, which is always faster than harddrive file access read and write.
Last edited on
Topic archived. No new replies allowed.