Hello, working on a little Neural-net type thing, but I have a small issue, I want my data collecting program, to communicate data with my neural net program.
because they are both programs, I'm not sure if I can use Dll's (since, from my understanding, every time a program links to a DLL it creates a new instance of it)
also, since there is a fair bit of data being transferred, I don't want to make a text file that is constantly being updated, since that will wreck my hard drive pretty fast.
is there a way I can set aside a portion of RAM, use one text file to communicate the pointer to that RAM location, and do it that way? I'm aware that this can be dangerous (if one program closes, freeing that ram area for other programs, and the other app keeps trying to pull/write data from that location it could cause major issues, but I think I can prevent that)
so right now I have one program doing this:
1 2 3 4 5 6 7 8
|
void OutputData(int &Number)
{
ofstream myfile;
myfile.open("C:/Testing/example.txt", ios::binary);
myfile << &Number; // Write a pointer location to that int.
myfile.close();
}
| |
and the other program doing this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void main()
{
//read text file to get a memory location.
string line;
ifstream myfile("C:/Testing/example.txt", ios::binary);
if (myfile.is_open())
{
while (getline(myfile, line))
{
cout << line << '\n';
}
myfile.close();
}
else cout << "Unable to open file";
//print out what that memory location says.
int *a = (int*)line;
cout << a << " Just checking " << endl;
cin.get();
}
| |
of course the " int *a = (int*)line; " part doesn't work due to mis-matching data types, but you see my idea (I hope)
but I can't shake the feeling there must be a better way.