You are on page 1of 2

CHARECTER COUNT (SENDER) #include<stdio.h> #include<fcntl.h> #include<string.

h> int main() { int fd,len1=0,l1,i=0,j=0; char msg[20],ms1[25],l[3],smsg[50]; fd=open("fcon1",O_WRONLY); printf("\nEnter the length :: "); scanf("%s",l); printf("\nEnter the Sting"); scanf("%s",msg); l1=strlen(l); if(i<=l1) { smsg[i]=l[i]; i=i++; } smsg[i++]='#'; if(i>l1) { for(j=0;j<strlen(msg);j++) { smsg[i]=msg[j]; i++; } } printf("\n %s %d",smsg,i); write(fd,smsg,i); return 0; } -:OUTPUT:[divya@linux nt]$ gcc -o data1 cc_s.c [divya@linux nt]$ ./data1 Enter the length :: 5 Enter the Stingdivya 5#divya 7 Or [exam27@localhost exam27]$ ./a.out scount Enter the length :: 5 Enter the Stingbhumi 5#bhumi 7 (RECIVER)

#include<stdio.h> #include<fcntl.h> int main() { char msg[80],t[10]; int fd,len,i,j,l; mknod("fcon1",010666,0); fd=open("fcon1",O_RDONLY); read(fd,msg,len); for(i=0;msg[i]!='#';i++) t[i]=msg[i]; l=atoi(t); for(j=i+1;j<=l+1;j++) { printf("%c",msg[j]); } return 0; } -:OUTPUT:[divya@linux nt]$ gcc -o data2 cc_r.c [divya@linux nt]$ ./data2 divya or [exam27@localhost exam27]$ cc rcount.c [exam27@localhost exam27]$ ./a.out rcount bhumi [exam27@localhost exam27]$

You might also like