Program:
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/msg.h>
#include<sys/shm.h>
#include<unistd.h>
#include<stdio.h>
#include<sys/stat.h>
#include<string.h>
main()
{
int shmid,i,len;
char *pa,a[1000];
shmid=shmget((key_t)1300,1024,0600|IPC_CREAT);
if(shmid==-1)
{printf("shmget
failed");
return;
}
pa=(char*)shmat(shmid,0,0);
if(pa==(void *)-1)
{
printf("shmat
failed");
return;
}
len=strlen(pa);
printf("\nThe
length of the text is : %d\n",len);
}
OUTPUT:
[user @localhost
~]$ cc lenshm.c
[user @localhost
~]$ ./a.out
The length of the
text is : 54
[user @localhost
~]$
No comments:
Post a Comment
Thanks for your valuable comments