Warning: include(topsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/string_manupulation.html on line 13

Warning: include(topsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/string_manupulation.html on line 13

Warning: include(): Failed opening 'topsc.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eng123/public_html/sourcecode/c/unix/string_manupulation.html on line 13

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)  
 


Warning: include(adsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/string_manupulation.html on line 31

Warning: include(adsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/string_manupulation.html on line 31

Warning: include(): Failed opening 'adsc.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eng123/public_html/sourcecode/c/unix/string_manupulation.html on line 31

 
String manipulation using message Queue

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

Description : This program is used to perform the string manipulation using message Queue.contains 4 programs.one program is used as the header.one program for used to send the data int the messga queue and other two programs are used to reterive the message.

Queue.h
-------
#include<stdio.h>
#include<errno.h>
#include<sys/ipc.h>
#include<sys/msg.h>
struct queue
{
long type;
char msg[50];
};

Queue.c
-------

#include "queue.h"
int main()
{
struct queue q;
int mid;
if((mid=msgget(ftok("string",0x99),0644|IPC_CREAT))<0)
{
if(mid!=-1)
{
printf("Message Queue Error<BR>);
exit(1);
}
else
{
printf("Message Already Exist<BR>);
exit(1);
}
}
printf("
Enter the Message Type:");
scanf("%d",&q.type);
while(q.type>0)
{
printf("
Enter the Message:");
getchar();
gets(q.msg);
if(msgsnd(mid,&q,sizeof(q),IPC_NOWAIT)<0)
{
printf("Message send Error<BR>);
exit(1);
}
printf("
Enter the Message Type:");
scanf("%d",&q.type);
}
return 0;
}


Word.c
------

#include "queue.h"
#include<string.h>
void word(char* str)
{
int i,n,w=1;
n=strlen(str);
for(i=0;i<n;i++)
if(str[i]==' ' && str[i-1]!=' ')
w++;
printf("Number of Words in "%s" :%d<BR>,str,w);
}

int main()
{
struct queue q;
int mid;
long type;
if((mid=msgget(ftok("string",0x99),0644 ))<0)
{
printf("Message Queue Error<BR>);
exit(1);
}
printf("
Enter the Message Type to Reterive:");
scanf("%d",&type);
while(msgrcv(mid,&q,sizeof(q),type,IPC_NOWAIT) && errno!=ENOMSG)
{
word(q.msg);
}
msgctl(mid,IPC_RMID,NULL);
}

Reverse.c
---------

#include "queue.h"
#include<string.h>
void rev(char* str)
{
char s[30];
int i,j,n;
n=strlen(str);
printf("Reverse for "%s" :",str);
for(i=n;i>=0;i--)
putchar(str[i]);
printf("<BR>);
}
int main()
{
struct queue q;
int mid;
long type;
if((mid=msgget(ftok("string",0x99),0644 ))<0)
{
printf("Message Queue Error<BR>);
exit(1);
}
printf("
Enter the Message Type to Reterive:");
scanf("%d",&type);
while(msgrcv(mid,&q,sizeof(q),type,IPC_NOWAIT) && errno!=ENOMSG)
{
rev(q.msg);
}
}


 

 

 

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