write a C program to print the program itself ?!

Answer Posted / vinay tiwari

this can be achieved by file handling

#include<stdio.h>
void main()
{
FILE *fp;
char ch;
clrscr();
fp=fopen("file.c","r");
ch=getc(fp);
while(ch!=EOF)
{
putchar(ch);
ch=getc(fp);
}
getch();
}

Is This Answer Correct ?    63 Yes 33 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain continue keyword in c

578


Explain the difference between call by value and call by reference in c language?

637


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

1639


please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

1319


What is const and volatile in c?

561






Can you please explain the difference between malloc() and calloc() function?

609


a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

630


What is unsigned int in c?

551


How do you use a pointer to a function?

626


Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?

2170


What are the loops in c?

589


explain how do you use macro?

664


Define the scope of static variables.

599


PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE

1464


When should a type cast not be used?

622