c++ - Why is Runtime Error popping up? -
can please me in this? why runtime error popping up? in advance:) not c++.
#include <iostream> #include<sys/types.h> #include<sys/ipc.h> #include<sys/shm.h> #include<string.h> #include<unistd.h> #define key 123456 using namespace std; int main() { int shmid=shmget(key, 128, 0666); char* addr1=(char*)shmat(shmid, 0, 0); strcpy(addr1, "hello"); int pid=fork(); if(pid!=0) { char* addr2=(char*)shmat(shmid,0,0); std::cout<<"\n"<<addr1; std::cout<<"\n"<<addr2; sleep(2); std::cout<<"\n"<<addr1; std::cout<<"\n"<<addr2; int rval=shmdt(addr2); std::cout<<"\n"<<addr1; std::cout<<"\n"<<addr2; } else { strcpy(addr1, "world"); } return 0; }
can please me in this? why runtime error popping up? in advance:) not c++. can please me in this? why runtime error popping up? in advance:) not c++. sorry had make content larger.
Comments
Post a Comment