How do you write a program which produces its own source
code as its output?
Answer Posted / vivek
printitself.c
#include <stdio.h>
int main()
{
char ch;
FILE *file;
file=fopen("printitself.c","r");
while((ch=fgetc(file))!=EOF)
printf("%c",ch);
return 0;
}
| Is This Answer Correct ? | 19 Yes | 2 No |
Post New Answer View All Answers
When should volatile modifier be used?
Why does the call char scanf work?
Why is c called a mid-level programming language?
What is the difference between typedef struct and struct?
State the difference between realloc and free.
Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.
What’s the special use of UNIONS?
What are different types of pointers?
What 'lex' does?
What is the -> in c?
Why doesnt the call scanf work?
Which one would you prefer - a macro or a function?
struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer
What is the use of bit field?
How will you declare an array of three function pointers where each function receives two ints and returns a float?