谢谢 https://blog.csdn.net/gdutlyp/article/details/50468677
我的代码
cpp写入端
#include <QCoreApplication>
#include <QSharedMemory>
#include <iostream>
#include <QByteArray>
using namespace std;
/* shares memory */
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QByteArray ba(1024,0);
for(int i=0;i<1024;i++)
{
ba[i] = i;
}
QSharedMemory sm("rbt"); //set key
sm.create(4096,QSharedMemory::ReadWrite); //set mode
sm.attach();
bool ret = sm.isAttached();
ret ? cout<<"sucess"<<endl : cout<<"failed"<<endl;
sm.lock();
char* smd = (char*)sm.data(); //get shared memory address
memcpy(smd,ba.constData(),1024);
sm.unlock();
sm.unlock();
char c;
cin>&