23CHI077

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Roll No:23CHI077

NAME:PAGHADAR PREM
Course Code and Name: 2CS101, Computer Science
Practical No : 10-a
Aim : To calculate length of a file

Methodology :
#include <stdio.h>
int main()
{
FILE *fp;
long int size=0;
fp=fopen("temp.txt","r");
fseek(fp,0,SEEK_END);
size=ftell(fp);

if(size!=-1)
printf("File size is: %ld\n",size);
else
printf("There is some ERROR.\n");

return 0;
}

Theoretical concepts: file handling


Input and Output:

Practical No: 10-b


Aim : To concatenate two files
Methodology used:
#include <stdio.h>
void main()
{
FILE *fp;
FILE *fl;
fp=fopen("temp.txt","a");
fl=fopen("temp1.txt", "r");

char arr[40];
fscanf(fl, "%s", &arr);
fprintf(fp, "%s", arr);

}
Theoretical concepts: file handling
Input and Output:

Practical No : 10-c
Aim : To copy the content of one file to another
Methodology :
#include <stdio.h>
void main()
{
FILE *fp;
FILE *fl;
fp=fopen("temp.txt","w");
fl=fopen("temp1.txt", "r");

char arr[40];
fscanf(fl, "%s", &arr);
fprintf(fp, "%s", arr);

}
Theoretical concepts: file handling
Input and Output:

Conclusion :
We performed this experiment by successfully using file handling.

You might also like