Wednesday 19 February 2014

How to create Charcter Count detection in Linux programming

-------------------------
Sender side code
-------------------------
#include<stdio.h>
#include<fcntl.h>
#include<string.h>

void main()
{
    int fout,cnt;
    char msg[20];

    printf("\n\n\t\tENTER YOUR MESSAGE :");
    gets(msg);
    cnt=strlen(msg);
    fout=open("pipe",O_WRONLY);
    write(fout,&cnt,sizeof(int));
    write(fout,&msg,cnt);

    close(fout);
     printf("YOUR MESSAGE SUCCESSFULLY SEND..!!! ");
}

------------------------------------------------
Reciver side code
------------------------------------------------

#include<stdio.h>
#include<fcntl.h>
#include<string.h>

void main()
{
    int fout,cnt,len;
    char msg[20];

    fout=open("pipe",O_RDONLY);



    read(fout,&cnt,sizeof(int));
    read(fout,&msg,cnt);

   len=strlen(msg);
     if(len==cnt)
    {
   printf("\n\n\t\tYOUR MESSAGE : %s SIZE:%d",msg,cnt);

     printf("YOUR MESSAGE SUCCESSFULLY RECIVED..!!! ");

    }
   else
    { printf("YOUR MESSAGE NOT SUCCESSFULLY RECIVED..!!! ");}
   close(fout);
}
---------------------------------------------------------
HOW TO RUN IT

STEP 1 :>CREATE TWO FILE SENDER.C AND RECIVER.C IN VI EDITOR

STEP 2 :> COMPILE THOSE TWO FILE AS BELOW
 
                      cc sender.c -o sender.out

                      AND NEXT FILE FOR RECIVER
   
                      cc reciver.c -o reciver.out
STEP 3 :>NOW YOU HAVE TO PUT RECIVER SIDE RUNNING PROCESS  IN BACKGROUND
           
                      ./reciver.out &
             
                  ABOVE CODE GENERATE THE BACKGROUND PROCESS OF RECIVER.C
STEP 4 :> NOW RUN SENDER FILE
             
                 ./sender.out

IF YOU NOT DONE AS ABOVE INSTRUCTION THEN CONTACT ME OR LEAVE COMMENT

1 comment:

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...