2. Table of Contents
Introduction
What to do ?
Technique used
How it works ?
Applications
Queries
3. File Remotio
CONTENTS
Remotio – shifting
Introduction
This is about the shifting of files in C language.
What to do ?
Technique used
How it works?
Applications
Queries
The basic concept we all know about swapping is
a=5
b=6
after shifting
a=6
b=5
This could be done either by using temporary variable or by swap
function.
but how to do with files…??
Let’s switch to the question
4. Task with Condition
CONTENTS
Introduction
What to do?
Design a program that circularly swaps the contents of files.
for example 3 files are taken as input then the content of file1
to file 2 then, file2 to file3 then, file3 to file1
Technique used
The program should scale well to certain number of files.
How it works?
Also assert the number of words in each file which will also
should be changed when swapping is occurred .
Applications
Queries
6. STEP 1: Start the program .
CONTENTS
Introduction
STEP 2:Include the header files and function prototyes Declare the functions
check and swp which are used then,the integer variables I,n
and bf and aaf with array size 50.
STEP 3: Declare the character variables txtbf and txtaf with array size 50
and assign the name of array as”a.txt”.
STEP 3: Create a file pointer fp of size 50.
What to do ?
STEP 4: Print the number of files to open and get in n.
Technique used
STEP 5: Initialize i equal to 0 and check whether it is less than n and if so it
will create the new files and the contents will be displayed in file
till n number of times else it will print “file is not created
successfully. “.
(Algorithm)
How it works?
Applications
Queries
STEP 6: Again check the same condition and if it satisfied call the function
check and store the content in bf then by the given statement the
contents are copied to txtbf [].
STEP 7: In the check function it initialize tlen o ‘0’and the count will be
increased till it reaches the EOF (End Of File) and then the len will
be returned .
STEP 8: : Promote the same looping conditions and if it satisfied it calls the
swp function
7. CONTENTS
Introduction
What to do ?
Technique used
(Algorithm)
How it works?
Applications
Queries
STEP 9: In the swp function two variables t1 and t2 are created the contents of
file 1 will be copied to t1 and t2 will be placed on file1and then t1 to t2
and the cycle will be continued till the condition satisfies .
STEP 10: At last content of the file and the lengh of the file before and after
swapping will be printed .
STEP 11: Get the output and end the program.
8. #include<stdio.h>
CONTENTS
Introduction
What to do ?
Technique used
How it works?
(Source code)
#include<string.h>
int check(FILE *fp);
void swp(FILE *fp);
void main()
{
int i,n,bf[50],af[50];
char name[6]="a.txt",txtbf[50][50],txtaf[50][50];
FILE *fp[50];
clrscr();
Applications
printf("Enter number of files to open :");
Queries
scanf("%d",&n);
15. CONTENTS
Introduction
What to do ?
Technique used
How it works?
Applications
Queries
How it is used
• It will be useful for those who wants to shift the entire
stuff from one place to another that is to transfer the
whole thing.
• It is also useful to analyze the total number of contents
in each file before shifting that is to verify it before it
proceed
• Keeping this as the base and doing further development
this application can be used significantly in many other
aspects