Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Thursday, 27 June 2013

How to use Command line argument in GCC compiler

[Sender.c]
#include<stdio.h>
#include<fcntl.h>
#include<string.h>
void main(int argc, char *args[])
{
int i,count=0,len,j=0,pid;
char frame[50],data[50];
        len=strlen(args[1])-8;

system("clear");
system(">pipe");
pid=open("pipe",O_WRONLY);

printf("len : %d",len);
printf("%s",data);

for(i=0; i<len; i++)
{
data[i]=args[1][8+i];
}
data[i]='\0';
printf("data %s",data);

frame[j]=len+48;
for(i=0; i<len; i++)
{
j++;
frame[j]=data[i];
}
j++;
frame[j]='\0';
printf(" Sent to frame :%s",frame);
write(pid,&frame,sizeof(frame));
}

[Receiver.c]

#include<stdio.h>
#include<fcntl.h>
#include<string.h>
void main()
{
int i,count=0,len,j=0,pid;
char frame[50],data[50];
        system("clear");
pid=open("pipe",O_RDONLY);
read(pid,&frame,sizeof(frame));
printf("%s",frame);
len=strlen(frame);
for(i=0; i<len; i++)
{
data[i]=frame[i+1];
}
data[i]='\0';
printf("data %s",data);
printf("\n receive to frame :%s",data);
}




3 comments:

  1. New Forum Website lunched For Testing Purpose register your self on
    http://gtuforum.com
    Enjoy Discussion with Fun!

    ReplyDelete
  2. Your Programs are awesome.. They are really helpfull

    ReplyDelete
  3. in exam they are asking all simple programs like bit stuffing with any noiseless protocol... nd how to do that programs?

    ReplyDelete