第一次使用共享内存,我的项目是让读取器和写入器访问共享字符串并修改或读取它们等。我知道 malloc 不起作用但不确定如何将二维字符串数组附加到内存,我继续从编译器那里得到这个:
警告:赋值从没有强制转换的指针生成整数
int array_id; // id for the shared memory segment
char records[10][50]; // the shared memory segment array
// attach the reader to the shared segment
fread(&newrecord, sizeof(id_record), 1, id_file);
array_id = newrecord.id;
printf("%d\n", array_id);
records[0][0] = (char**) shmat(array_id, (void*) 0, 0);
if (records[0] == (void*)-1) {
perror("Array Attachment Reader");
}
arrayid 是正确的,我已经三重检查了它没有提出来。
谢谢