Untitled

 avatar
unknown
c_cpp
8 days ago
433 B
3
Indexable
#include <iostream>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <cstring>

int main() {
    key_t key = ftok("shmfile", 65);
    int shmid = shmget(key, 1024, 0666 | IPC_CREAT);

    char* str = static_cast<char*>(shmat(shmid, nullptr, 0));

    std::cout << "Write Data: ";
    std::cin.getline(str, 1024);

    std::cout << "Data written in memory: " << str << std::endl;

    shmdt(str);

    return 0;
}
Editor is loading...
Leave a Comment