FILE Remotio
- Niranjj.S CSE-A
Table of Contents
 Introduction
 What to do ?
 Technique used
 How it works ?
 Applications
 Queries
File Remotio
CONTENTS

Remotio – shifting

 Introduction

This is about the shifting of files in C language.

 What to d...
Task with Condition
CONTENTS
 Introduction



What to do?

Design a program that circularly swaps the contents of files....
CONTENTS

File5

File1

 Introduction
 What to do ?

Technique used

(pictorial)

File4

File2

 How it works ?
 Appl...
STEP 1: Start the program .

CONTENTS
 Introduction

STEP 2:Include the header files and function prototyes Declare the f...
CONTENTS
 Introduction
 What to do ?

Technique used

(Algorithm)
 How it works?

 Applications
 Queries

STEP 9: In...
#include<stdio.h>

CONTENTS
 Introduction
 What to do ?
 Technique used


How it works?
(Source code)

#include<string...
for(i=0;i<n;i++)
{

CONTENTS

name[0]='a'+i;

 Introduction

if((fp[i]=fopen(name,"w+"))==0)

 What to do ?

{
printf("n...
for(i=0;i<n;i++)
{

CONTENTS

bf[i]=check(fp[i]);

 Introduction

rewind(fp[i]);

 What to do ?

fgets(txtbf[i],49,fp[i]...
for(i=0;i<n;i++)

{

CONTENTS

af[i]=check(fp[i]);

 Introduction

rewind(fp[i]);

 What to do ?

fgets(txtaf[i],49,fp[i...
printf("n-------------------------------------------------");}

getch();

CONTENTS

}int check(FILE *fp)

 Introduction

...
void swp(FILE *fp)// receive fp

CONTENTS

{
char t1[50],t2[50];

 Introduction

rewind(fp);

 What to do ?

fgets(t1,49...
CONTENTS
 Introduction
 What to do ?
 Technique used


How it works?
(Output)

 Applications
 Queries
CONTENTS
 Introduction
 What to do ?
 Technique used
 How it works?

Applications
 Queries

How it is used
• It will...
File Remotio
File Remotio
Upcoming SlideShare
Loading in...5
×

File Remotio

66

Published on

This presentation is about the shifting of file content from one file to another.
This is done using C programming .

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
66
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

File Remotio

  1. 1. FILE Remotio - Niranjj.S CSE-A
  2. 2. Table of Contents  Introduction  What to do ?  Technique used  How it works ?  Applications  Queries
  3. 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. 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
  5. 5. CONTENTS File5 File1  Introduction  What to do ? Technique used (pictorial) File4 File2  How it works ?  Applications  Queries File3
  6. 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. 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. 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);
  9. 9. for(i=0;i<n;i++) { CONTENTS name[0]='a'+i;  Introduction if((fp[i]=fopen(name,"w+"))==0)  What to do ? { printf("nFile NOT created successfullyn");  Technique used }  How it works? (Source code) else {  Applications fprintf(fp[i],"%s%d","contents of file ",i+1);  Queries printf("File created successfullyn"); } }
  10. 10. for(i=0;i<n;i++) { CONTENTS bf[i]=check(fp[i]);  Introduction rewind(fp[i]);  What to do ? fgets(txtbf[i],49,fp[i]);  Technique used  How it works? (Source code) } for(i=0;i<n;i++) { swp(fp[i]);  Applications }  Queries swp(fp[0]);
  11. 11. for(i=0;i<n;i++) { CONTENTS af[i]=check(fp[i]);  Introduction rewind(fp[i]);  What to do ? fgets(txtaf[i],49,fp[i]);  Technique used } for(i=0;i<n;i++)  How it works? (Source code) { printf("nnBefore swapping : nFILE %d : %s",i+1,txtbf[i]);  Applications printf("nlength of FILE %d : %d",i+1,bf[i]);  Queries printf("nnAfter swapping : nFILE %d : %s",i+1,txtaf[i]); printf("nlength of FILE %d : %d",i+1,af[i]);
  12. 12. printf("n-------------------------------------------------");} getch(); CONTENTS }int check(FILE *fp)  Introduction { int len=0;  What to do ? rewind(fp);  Technique used while(getc(fp)!=EOF)  How it works? (Source code) { len++;  Applications }  Queries return len; }
  13. 13. void swp(FILE *fp)// receive fp CONTENTS { char t1[50],t2[50];  Introduction rewind(fp);  What to do ? fgets(t1,49,fp);  Technique used rewind(fp);  fputs(t2,fp); How it works? (Source code)  Applications  Queries strcpy(t2,t1); }
  14. 14. CONTENTS  Introduction  What to do ?  Technique used  How it works? (Output)  Applications  Queries
  15. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×