Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
String manipulation using shared memory

--------------------------------------------------------------------------------

Description : string manipulation using shared memory.... "A Process say p1 has to create the shared memory to store a line of text.Another Process say p2 has to perform the substring operation and it is displayed in process p2 itself."

Process p1
----------

#include<sys/shm.h>
int main()
{
size_t length;
struct shmid_ds buff;
char *ptr,p[50];
int id,i;
printf("
Shared Memory");
printf("
------ ------");
if((id=shmget((key_t)6234,2,0664|IPC_CREAT))<0)
{
printf("Shared Memory Creation Error<BR>);
exit(1);
}
ptr=shmat(id,NULL,0);
printf("
Enter the string :");
gets(p);
puts(p);
for(i=0;i<strlen(p);i++)
*ptr++=p[i];
printf("The Entered String %s was Accepted.<BR>,ptr);
exit(0);
}


Process p2
----------

#include<stdio.h>
#include<sys/shm.h>
int main()
{
size_t length;
struct shmid_ds buff;
char *ptr,a[50],b[10],c[20];
int id,i=0,flag=0,j,k=0;
if((id=shmget((key_t)6234,2,0664|IPC_CREAT))<0)
{
printf("Shared Memory Creation Error<BR>);
exit(1);
}
printf("
Shared memory Created : %d",id);
ptr=shmat(id,NULL,0);
memset(a,'
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG