write this program and save it as pro.c....run....it will show the program to the consol and write the source code into data.txt file...................
#include <iostream> #include <fstream> #include <string> using namespace std;
int main () { string line;
fstream myfile; myfile.open("test.cpp",ios::in); /* or use this: ifstream myfile; myfile.open("test.cpp"); */
if(myfile.is_open()){ while(! myfile.eof()){ getline(myfile,line); cout << line <<endl; } myfile.close(); }else{ cout<<"unable to open the file"; } return 0; }
class abc { public : int main() { cout<<" Its main function "<<endl; return 0; } };
int main(int c, char **v) { abc a; /******************That will print the output**********/ char buff[100]; strcpy(buff, "type "); strcat(buff, __FILE__); system(buff); /******************************************/ printf(" Address of main Function = %u ",main); if(c<1) { cout<<" Error can not accept it "; } cout<<" its in main program "<<a.main()<<endl;