+ 23
Can anybody tell me how can we print the source code as a output of the program?
22 Respostas
+ 28
For Python, you can just add this to your code:
print(open(__file__).read())
For C:
char c;
FILE *f;
f=fopen(__FILE__, "r");
while((c=fgetc(f))!=EOF){
putchar(c);
}
The others should be similar.
+ 14
FYI / to help you use search, a program that prints its own source code is called a 'quine'.
+ 10
Kishalaya Saha This is working Thanks for our help😇
+ 6
Kirk Schafer Thanks for your help😊
+ 6
徐寿成 Will you please talk in English?
+ 5
You're welcome, Prajakta 😊
+ 5
Python code.
print(open(__file__).read())
+ 5
Anand Chaklasiya Thanks 😊
+ 4
i will give java source code later
+ 4
Alex Thanks for your help😊
I'm waiting for your java source code.
Thank You
+ 3
if you know how to scan text files in any of the languages then put the source code in the .txt file
+ 3
Alex What do you mean?
+ 1
for c++
cout<<"whatever you want to print out"<<endl;
ex:
cout<<"Enter the value of a number"<<endl;
cin>>num1; //cin is to take in information
0
Kishalaya Saha Thanks
0
sorry what I say is the same function in c is so fussy while in python is just one line(my English is not very good ,there may be some questions in my expression)
0
oh i am very sorry
0
no it isnt
0
for php do
$youvariable = file_get_contents(‘yourdomain’);
- 1
😊
- 1
Emilija Radvilate is super hot, seriously.
Alex
Stop spamming such comments. They're not related to programming, let alone these threads.