Write a program to convert uppercase letter to lower case in file .
 
इस उदहारण मे , file मे
उपस्थित किसी uppercase letter को lower case में convert करना है 
 
 
1.सबसे पहले file को read mode के साथ open किया
जाता है |
 
2.उसके बाद एक temporary
file ‘temp’ को creat किया
जाता है जिसके file pointer
‘ft’ है |
 
3.file मे से character को  read किया जाता है और इस character को character variable ‘c’  मे store करा देते
है |
 
5.इसके बाद इस character को lower case मे convert कर देते है और इस converted character को temporary file मे store करा देते है |
 
6.step 3 से step 5 तब तक repeat है जब तक file का end नहीं हो जाता है |
 
7.इसके बाद temporary file का नाम file name से rename कर देते है |
 
9 .सभी file को क्लोज कर देते है | 
 
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
 
void convert(FILE * f,const char *c);
 
printf(“Enter File name”);
 
printf(“Unable to open files”);
 
prtintf(“Please Check File Exitense”);
 
void convert(FILE *f, const char *file)
 
ft=fopen(“Temp.doc”,”w”);
 
printf(“Unable to open files”);
 
prtintf(“Please Check File Existent”);
 
while((c=fgetc(f)) != EOF)
 
Write a program to convert lowercase letter to uppercase in file .
 
इस उदहारण मे ,file मे उपस्थित किसी lowercase letter को uppercase में convert करना है |
 
1.सबसे पहले file को read mode के साथ open किया जाता है |
 
2.उसके बाद एक temporary file ‘temp’ को create किया जाता है जिसके file pointer ‘ft’ है |
 
3.file मे से character को  read किया जाता है और इस character को character variable ‘c’  मे store करा देते है |
 
5.इसके बाद इस character को uppercase मे convert कर देते है और इस converted character को temporary file मे store करा देते है |
 
6.step 3 से step 5 तब तक repeat है जब तक file का end नहीं हो जाता है |
 
7.इसके बाद temporary file का नाम file name से rename कर देते है |
 
9 .सभी file को क्लोज कर देते है | 
 
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
 
void convert(FILE * f,const char *c);
 
printf(“Enter File name”);
 
printf(“Unable to open files”);
 
prtintf(“Please Check File Exitense”);
 
void convert(FILE *f, const char *file)
 
ft=fopen(“Temp.doc”,”w”);
 
printf(“Unable to open files”);
 
prtintf(“Please Check File Exitense”);
 
while((c=fgetc(f)) != EOF)
 
 
Write a program to display own source code of a program .
 
इस उदहारण मे , किसी प्रोग्राम मे लिखे जाने वाले code को आउटपुट screen मे display किया जाता है |
 
इस task के लिए , current file की location को पता लगना होता हो बाकि read and print function से task complete हो जाता है |
file की location लेन के लिए pre processor _file_को use किया जाता है |इसके अलावा कई और preprocessor होते है जैसे 
-_line_ : इसका use current line के number को use करने के लिए किया जाता है |
-_DATE_ : इसका use आज की date को point करने के लिए किया जाता है |
-_TIME_ : इसका use current time को use करने के लिए किया जाता है |
-_FUNCTION_  : इसका use current function के नाम को use करने के लिए किया जाता है |
 
#include<stdio.h>
 
#include<conio.h>
 
 
printf(“Unable to open files”);
 
prtintf(“Please Check File Exitense”);
 
while(c=fgetc(f) != EOF)
{
printf(“%c”,c);
}
 
Write a program to count occurrence of all words in file  .
 
इस उदहारण मे ,file मे आने वाले सभी words की calculate किया जाता है |
 
1.सबसे पहले file को read mode के साथ open किया जाता है |
 
2.उसके बाद एक string  को create किया जाता है| और एक और array count[] को declare करते है जो की words के count को hold करता है |
 
3.file मे से word को  read किया जाता है और इस word को string variable ‘word’  मे store करा देते है |
 
4.इसके बाद इस word को lowercase मे convert कर देते है और अगर word मे से last punctuation  character को remove कर देते है |
 
5.इसके बाद word को file content में check किया जाता है |
अगर word exit है तब word से related count मे ‘1’ से increment हो जाता है |
7.step 3 से step 5 तब तक repeat होगी जब तक file का end नहीं हो जाता है |  
 
#include<stdio.h>
 
#include<conio.h>
 
#include<stdlib.h>
 
 
char filename[100];
char word[100];
int i, length,index, is;
char words[100][100];
int count[100];
 
printf(“Enter File name”);
 
printf(“Unable to open files”);
 
prtintf(“Please Check File Exitense”);
 
for(i=0;i<100;i++)
{
count[i]=0;
index=0;
while(fscanf(f,”%s”,word) != EOF)
{
strlwr(word);
length=strlen(word);
if(ispunct(word[length-1]))
{
word[length-1]=’\0′;
is=1;
for(i=0;i<index && is;i++)
 
{
if(is)
{
strcmp(words[index], word)
index++;
}
else
{
count[i-1]++;
}
}
fclose(f);
printf (“word with count list “)
for(i=0;i<index;i++)
{
printf (“%s : %d”,word[i],count[i]);
}
getch();
 
Write a program to merging operation of two files .
 
इस उदहारण मे ,दो files को merge किया जाता है |
 
1.सबसे पहले दोनों files को read mode के साथ open किया जाता है |
 
2.उसके बाद एक file को create किया जाता है| जिसका mode write है |
 
3. file1 मे से data  को  read किया जाता है और इस data को file 3 मे write करा देते है |
 
4.जब file 1 मे reading operation हो जाता है तब file 2 मे से data  को  read किया जाता है और इस data को file 3 मे write करा देते है |
 
5.इसके बाद तीनो file को close कर दिया जाता है |
 
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
 
char filename1[100];
char filename2[100];
char mergefile[100];
 
printf(“Enter File name 1:”);
 
gets(filename1);
printf(“Enter File name 2:”);
 
gets(filename2);
printf(“Enter merge file name :”);
 
 
 
f1=fopen(filename1,”r”);
f2=fopen(filename2,”r”);
f3=fopen(mergefile,”w”);
 
if (f1==NULL || f2==NULL || f3==NULL  )
 
printf(“Unable to open files”);
 
prtintf(“Please Check File Exitense”);
 
while(c=fgetc(f1) != EOF)
{
fputc(c,f3);
}
while(c=fgetc(f2) != EOF)
{
fputc(c,f3);
}
fclose(f1);
fclose(f2);
fclose(f3);
 
}
 
Write a program to copying operation in files .
 
इस उदहारण मे ,files मे copy operation को perform  किया जाता है |
 
1.सबसे पहले  file को read mode के साथ open किया जाता है |
 
2.उसके बाद एक file को create किया जाता है| जिसका mode write है |
 
3. file मे से data  को  read किया जाता है और इस data को file 2 मे write करा देते है |
 
4.इसके बाद दोनों  files को close कर दिया जाता है |
 
#include<stdio.h>
 
#include<conio.h>
 
#include<stdlib.h>
 
 
char filename1[100];
char filename2[100];
 
printf(“Enter File name 1:”);
 
gets(filename1);
printf(“Enter File name 2:”);
 
 
f1=fopen(filename1,”r”);
f2=fopen(filename2,”w”);
 
if (f1==NULL || f2==NULL)
 
printf(“Unable to open files”);
 
prtintf(“Please Check File Existent”);
 
while(c=fgetc(f1) != EOF)
{
fputc(c,f2);
}
fclose(f1);
fclose(f2);
 
}
 
Write a program to append operation in files .
 
इस उदहारण मे ,files मे copy operation को perform  किया जाता है |
 
1.सबसे पहले  file को append mode के साथ open किया जाता है |
 
2.उसके बाद file मे जिस data को enter करना है use input करा लेते है |
 
3. इस data को file  मे write करा देते है |
 
4.इसके बाद  file को close कर दिया जाता है |
 
#include<stdio.h>
 
#include<conio.h>
 
#include<stdlib.h>
 
 
char filename1[100];
char data[100];
 
printf(“Enter File name 1:”);
 
printf(“Unable to open files”);
 
prtintf(“Please Check File Existent”);
 
fputs(data,f1);
fclose(f1);
printf(“Unable to open files”);
 
prtintf(“Please Check File Existent”);
 
}
while(c=fgets(f1) != EOF)
{
printf(“%c”,c);
}
 
fclose(f1);
 
}
 
Write a program to distinct even or odd number from data of files .
 
इस उदहारण मे ,files के data मे से even और odd number अलग अलग  किया जाता है |
 
1.सबसे पहले दोनों files even और odd file  को write  mode के साथ open किया जाता है |
 
2.उसके बाद एक file को read mode के साथ open  किया जाता है| 
 
3. file मे से data  को  read किया जाता है और 
अगर data ब्वें है तब  इसे even file मे write करगे |
अन्यथा इसे odd file मे सेव करगे |
 
#include<stdio.h>
 
#include<conio.h>
 
#include<stdlib.h>
 
 
char filename1[100];
char filename2[100];
char mergefile[100];
int d;
 
printf(“Enter File name 1:”);
 
gets(filename1);
printf(“Enter File name 2:”);
 
gets(filename2);
printf(“Enter merge file name :”);
 
 
 
f1=fopen(filename1,”r”);
even=fopen(filename2,”w”);
odd=fopen(mergefile,”w”);
 
if (f1==NULL || f2==NULL || f3==NULL  )
 
printf(“Unable to open files”);
 
prtintf(“Please Check File Exitense”);
 
while(d=fscnaf(f1,”%d”,&d) != EOF)
{
if(d%2==0)
{
fprintf(even,”%d”,d);
}
else 
{
fprintf(odd,”%d”,d);
}
fclose(f1);
fclose(even);
fclose(odd);