Extract text From Shared Memory & Print it in Uppercase | URDINESH

Software Programming, Tutorials, Interview Preparations,Stock Market,BSE/NSE, General informations

Saturday, August 1, 2015

Extract text From Shared Memory & Print it in Uppercase


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;
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;
}
for(i=0;pa[i]!='\0';i++)
{
if(pa[i]>='a'&&pa[i]<='z')
pa[i]=pa[i]-32;
else
continue;
}
printf("\nUppercase Message : %s",pa);

}


OUTPUT:



[user @localhost ~]$ cc umgsh.c
[user @localhost ~]$ ./a.out

Uppercase Message : MESSAGE STORED IN SHARED MEMORY
SHARED MEMORY PROGRAMS
[user @localhost ~]$


No comments:

Post a Comment

Thanks for your valuable comments

Followers