DISPLAY SOURCE CODE AS OUTPUT IN C PROGRAM





#include<stdio.h>
int main(){
    FILE *p;
    char ch;
    p=fopen("raja.c","r");
    while((ch=getc(p))!=-1)
         putchar(ch);
    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.

7 comments:

Unknown said...

DISPLAY SOURCE CODE AS OUTPUT IN C PROGRAM


#include
int main(){
FILE *p;
char ch;
p=fopen("raja.c","r");
while((ch=getc(p))!=-1)
putchar(ch);
fclose(p);
return 0;
}

*********************************************8


hi, this program not given the correct output,, plz check and reply me,,,,,,,,,,,,,,,,,,,,,,,,,

TechGeek said...

hi can you help me in getting a program for counting paragraph from a file??

TechGeek said...

And also for the lines too. please help me.

Anonymous said...

frnd just replace "name of ur programe" instead of "raja.c" in this code and try it will work...

#include
int main(){
FILE *p;
char ch;
p=fopen("raja.c","r");
while((ch=getc(p))!=-1)
putchar(ch);
fclose(p);
return 0;
}

Anonymous said...

please help me out with a C program for displaying the contents of the file..and also adding the entered string to the file..!!

Unknown said...

can we give file name dynamically in this program ?

Unknown said...

you are closing the file in the while loop !