当前位置: 技术问答>linux和unix
共享内存操作程序问题
来源: 互联网 发布时间:2016-12-20
本文导语: 我执行./opshm 983057,这个程序为什么出现Segmentation fault错误啊! #include #include #include #include #include int main(int argc, char **argv) { int shm_id; char * shm_buf; if(argc != 2) { printf("the argc is wrong!"); ex...
我执行./opshm 983057,这个程序为什么出现Segmentation fault错误啊!
#include
#include
#include
#include
#include
int main(int argc, char **argv)
{
int shm_id;
char * shm_buf;
if(argc != 2)
{
printf("the argc is wrong!");
exit(1);
}
shm_id = atoi(argv[2]);
if((shm_buf = shmat(shm_id, 0, 0))
#include
#include
#include
#include
#include
int main(int argc, char **argv)
{
int shm_id;
char * shm_buf;
if(argc != 2)
{
printf("the argc is wrong!");
exit(1);
}
shm_id = atoi(argv[2]);
if((shm_buf = shmat(shm_id, 0, 0))