C program to print the source program itself: Please help me to solve this program. i am not getting in this question we have read a file and print content of it or what source program to print. help ma out.
itz easy man...u just need to know the file handling...Open the own source file (with .c extention) and show it to the console....lolzz....it ia a very common question...
I think it is a simple as this: Assuming you are running your program from the same folder as the source file, as TechForum4U mentioned u can just open the file directly : : : ifstream in("source.c"); string str(""); while (getline(in, str)) { cout << str; } : : of course you need to do the usual clean up and header imports. Thats my 5 cents.
Hey is simple. just open the source code file in your program through file handling. and all done. here are methods of File Handling http://www.google.com.pk/url?sa=t&s...yaGRDw&usg=AFQjCNFiaEP7PCchWeRb0eMTbMFHU5zusg
everyone here is correct... but I agree with shabbir.. use __FILE__ macro... and also understand __LINE__ marcro for future....