How to read a text file by c program










#include<stdio.h>
int main(){
char str[70];
FILE *p;
if((p=fopen("string.txt","r"))==NULL){
printf("\nUnable t open file string.txt");
exit(1);
}
while(fgets(str,70,p)!=NULL)
puts(str);
fclose(p);
return 0;
}










2.  Write a c program to delete a file.
3. Write a c program to copy a file from one location to other location.
6. Write a c program which writes string in the file.


Post a Comment