#include"stdio.h"
#include"conio.h"
#include"stdlib.h"
void getdata()
{
FILE *f1;
char c;
clrscr();
printf("\n\t\tEnter the data\n\t\t");
f1=fopen("sc.txt", "w");
while((c=getchar())!='\n')
putc(c, f1);
putc('\n', f1);
fclose(f1);
}
void send()
{
FILE *f1, *f2;
char c;
int i, k=0, windowsize=2, randno, k1;
f1=fopen("sc.txt", "r");
f2=fopen("ms.txt", "w");
loop:
for(i=0; i <>
{
c=getc(f1);
if(c!='\n')
{
printf("%c\n", c);
putc(c, f2);
k++;
}
else
goto end;
}
fclose(f1);
randomize();
randno=random(k);//generates a random number
f1=fopen("sc.txt", "a");
putc(randno, f1);
fclose(f1);
k1=randno;
printf("The Frames of data sent %d\n", k);
getch();
f1=fopen("sc.txt", "r");
fseek(f1, k, SEEK_SET);
goto loop;
end:
fclose(f1);
fclose(f2);
printf("The Frames of data sent %d\n", k);
}
void disp()
{
int choice;
printf("\n\tChoose an option\n");
printf("\n\t1.Send");
printf("\n\t2.Quit");
scanf("%d", &choice);
if(choice==1)
send();
}
void main()
{
clrscr();
getdata();
disp();
getch();
}
Labels
- ajax (1)
- Assembly Programming (3)
- Books on C++ (6)
- C Programs (35)
- Challenging Question (1)
- Class (1)
- Complete Script (1)
- Computer Graphics (1)
- CSS (2)
- Datastructure (6)
- Download (3)
- e-books (8)
- Errors (1)
- FTP (2)
- HTML (3)
- Interview Questions (8)
- Introduction (1)
- Methods (2)
- OOP (1)
- Operator Overloading (1)
- Operators (1)
- Others (5)
- PHP (4)
- PHP Errors (1)
- PHP Script (1)
- Programming (3)
- Question Bank (6)
- Short Questions (1)
- SQL (1)
- Tips (1)
- Tricks (1)
- Tricky Programs in C (2)
- Useful Scripts (1)
- WAP (1)
- Web (3)
- XHTML (1)
Simulation of Sliding Window Protocol
Thursday, August 19, 2010Posted by Xofth at 9:50 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment