Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

SIMULATION OF SLIDING WINDOW PROTOCOL in C

#include<stdio.h>
#include<conio.h>
void main()
{
char sender[50],receiver[50];
int i,winsize;
clrscr();
 printf("\n ENTER THE WINDOWS SIZE : ");
scanf("%d",&winsize);
 printf("\n SENDER WINDOW IS EXPANDED TO STORE MESSAGE OR WINDOW \n");
 printf("\n ENTER THE DATA TO BE SENT: ");
fflush(stdin);
gets(sender);
for(i=0;i<winsize;i++)
receiver[i]=sender[i];
receiver[i]=NULL;
 printf("\n MESSAGE SEND BY THE SENDER:\n");
 puts(sender);
 printf("\n WINDOW SIZE OF RECEIVER IS EXPANDED\n");
 printf("\n ACKNOWLEDGEMENT FROM RECEIVER \n");
for(i=0;i<winsize;i++);
printf("\n ACK:%d",i);
 printf("\n MESSAGE RECEIVED BY RECEIVER IS : ");
 puts(receiver);
 printf("\n WINDOW SIZE OF RECEIVER IS SHRINKED \n");
getch();
}

OUTPUT:
ENTER THE WINDOWS SIZE : 10

SENDER WINDOW IS EXPANDED TO STORE MESSAGE OR WINDOW

ENTER THE DATA TO BE SENT: ForgetCode.com

MESSAGE SEND BY THE SENDER:
ForgetCode.com

WINDOW SIZE OF RECEIVER IS EXPANDED

ACKNOWLEDGEMENT FROM RECEIVER

ACK:5
MESSAGE RECEIVED BY RECEIVER IS : ForgetCode

WINDOW SIZE OF RECEIVER IS SHRINKED