SlideShare uma empresa Scribd logo
1 de 17
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 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
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
CONTENTS

File5

File1

 Introduction
 What to do ?

Technique used

(pictorial)

File4

File2

 How it works ?
 Applications

 Queries

File3
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
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.
#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);
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");
}
}
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]);
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]);
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;
}
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);
}
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 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
File Remotio
File Remotio

Mais conteúdo relacionado

Mais procurados (6)

Introduction to PythonTeX
Introduction to PythonTeXIntroduction to PythonTeX
Introduction to PythonTeX
 
working with files
working with filesworking with files
working with files
 
Progress Report090806
Progress Report090806Progress Report090806
Progress Report090806
 
C# p4
C# p4C# p4
C# p4
 
Asynchronous JavaScript and Promises
Asynchronous JavaScript and Promises Asynchronous JavaScript and Promises
Asynchronous JavaScript and Promises
 
Austin Python Meetup 2017: What's New in Pythons 3.5 and 3.6?
Austin Python Meetup 2017: What's New in Pythons 3.5 and 3.6?Austin Python Meetup 2017: What's New in Pythons 3.5 and 3.6?
Austin Python Meetup 2017: What's New in Pythons 3.5 and 3.6?
 

Semelhante a File Remotio

This project is the first projects you will be working on this quart.pdf
This project is the first projects you will be working on this quart.pdfThis project is the first projects you will be working on this quart.pdf
This project is the first projects you will be working on this quart.pdf
eyewaregallery
 
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYC UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
Rajeshkumar Reddy
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
tutorialsruby
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
tutorialsruby
 

Semelhante a File Remotio (20)

VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5
 
Php basics
Php basicsPhp basics
Php basics
 
WEB TECHNOLOGIES- PHP Programming
WEB TECHNOLOGIES-  PHP ProgrammingWEB TECHNOLOGIES-  PHP Programming
WEB TECHNOLOGIES- PHP Programming
 
This project is the first projects you will be working on this quart.pdf
This project is the first projects you will be working on this quart.pdfThis project is the first projects you will be working on this quart.pdf
This project is the first projects you will be working on this quart.pdf
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
File handling.pptx
File handling.pptxFile handling.pptx
File handling.pptx
 
Flyr PHP micro-framework
Flyr PHP micro-frameworkFlyr PHP micro-framework
Flyr PHP micro-framework
 
Python Requirements File How to Create Python requirements.txt
Python Requirements File How to Create Python requirements.txtPython Requirements File How to Create Python requirements.txt
Python Requirements File How to Create Python requirements.txt
 
File Handling
File HandlingFile Handling
File Handling
 
File Handling
File HandlingFile Handling
File Handling
 
File management
File managementFile management
File management
 
Introduction to coding using Python
Introduction to coding using PythonIntroduction to coding using Python
Introduction to coding using Python
 
Php advance
Php advancePhp advance
Php advance
 
Unit_V_Files handling in c programming language.pptx
Unit_V_Files handling in c programming language.pptxUnit_V_Files handling in c programming language.pptx
Unit_V_Files handling in c programming language.pptx
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYC UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 

Último

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Último (20)

Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 

File Remotio

  • 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
  • 5. CONTENTS File5 File1  Introduction  What to do ? Technique used (pictorial) File4 File2  How it works ?  Applications  Queries File3
  • 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);
  • 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. 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. 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. 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. 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. CONTENTS  Introduction  What to do ?  Technique used  How it works? (Output)  Applications  Queries
  • 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