hey all i need reply fast plz
this is somewhat advance level c++ question .
Me and my friend are creating a small programming language in c++. which allows you to enter the code (in simpler language ) and the program converts it in the c++ code (which is contained in arrays )and saves it into a file with .cpp extension .
eg -
if you enter
number a=0
print hello"a"world
the above gets converted to
int a=0 ;
cout<<"hello"<<a<<"world";
and the above is shown on the screen and saved in a .cpp file .
i wanted to know that is there a way so that i can execute the above code in the program itself(or else i will have to open that .cpp file and then compile it )
I'm also new to cpp, but your idea seems to be great. Hope, someone in this forum can provide you great answers. You can also visit this website for more guidance: https://plus.google.com/113677802059243240271/
Yes, for most compilers the way to initially do it is to have the code compile to some other, probably lower-level language which then is compiled itself. (The other option is to not have a compiler at all, and instead just have it as an interpreted language).
As for your question, there are a variety of ways of doing this. The easiest way would be for your compiler to have the location of a compiler (probably on the PATH), and after compiling the program then makes it. For example, if your compiler is GCC, you could specify for your program that once it has determined that the .cpp file has been created successfully it will then execute the following:
g++ -O2 -std=c++11 -o filename.o filename.cpp -c
g++ -O2 -o filename.exe filename.o
Where 'filename' is the name of the program to compile, passed to your compiler.