shmat()

This is used to attach a shared memory segment to the given address space. That is, the shared memory identifier that's received by invoking the shmgt function needs to be associated with the address space of a process. Here is its syntax:

void *shmat(int shidtfr, const void *addr, int flag);

Here, we need to address the following:

If successfully executed, the function attaches the shared memory segment and returns the segment's start address, otherwise it returns -1.