write a C program to print the program itself ?!

Answer Posted / vikraman85

This can be achieved by file handling,
If r is the name of this file;The following codewil print
this prg.

#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 ?    19 Yes 23 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is the benefit of using const for declaring constants?

608


What is the time and space complexities of merge sort and when is it preferred over quick sort?

671


Which header file should you include if you are to develop a function which can accept variable number of arguments?

797


in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above

628


Write a program in c to replace any vowel in a string with z?

682






What does void main () mean?

723


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

594


How can a program be made to print the line number where an error occurs?

642


Explain what is the benefit of using #define to declare a constant?

604


In C programming, what command or code can be used to determine if a number of odd or even?

618


Is array name a pointer?

600


What is const and volatile in c?

561


What is static memory allocation?

597


Explain 'far' and 'near' pointers in c.

700


Explain how can I pad a string to a known length?

642