exe generates another exe
i have to make an exe that asks for some values and write another exe.
for example:
#include<iostream.h>
void main(){
int a,b;
a=5;b=3;
cout<<(a+cool.gif;
}
my program has to write a=6 and b=9 and generate the new exe with the new values.
how can i do that?
Re: exe generates another exe
Why dose it have to be a new exe?
Cant you just change a and b to the new values?
Or load a and b from a textfile and edit them when the program exits to the new values
Re: exe generates another exe
Why don't you describe the problem you're trying to solve instead of the proposed solution. There ought to be an easier way.
Re: exe generates another exe
it has to built exactly this way, it has to generate from a piece of code, another exe.
Re: exe generates another exe
Didn't we cover this in your other thread?
Re: exe generates another exe
not sure what u want to archive or why it HAS to be done like the way u mention besides all the alternative ideas the gave u , but heres how it can be done:
compile the new exe u want to "generate" and declare the 2 (or more) variables as strings like:
Code:
char* a = "MY STRING 1";
char* b = "MY STRING 2";
now the tool that ask for the new values will open the file , search and replace the hardcoded string values with the users input
u can also do that with a simple HEX editor for testing
but im really curious why u need to "generate" another exe based on user input :confused:
Re: exe generates another exe
I've been a member of this forum for over 8 years and this is probably the most bizarre question I've ever seen posted. Coopers, to you it may seem sensible to code your solution this way but please look at your question from the point of view of another programmer. It's a bit like asking "I need to design a wheelbarrow that can make other wheelbarrows". Or "I need to design a motorbike that can ride a motorbike".
As GCDEF said earlier, tell us about the problem you're trying to solve - not about your proposed solution. There's almost certainly a more sensible solution than the one you've asked for.
Or alternatively, if it genuinely does have to be solved this particular way, please explain why. :confused:
Re: exe generates another exe
Quote:
Originally Posted by
John E
I've been a member of this forum for over 8 years and this is probably the most bizarre question I've ever seen posted. Coopers, to you it may seem sensible to code your solution this way but please look at your question from the point of view of another programmer. It's a bit like asking "I need to design a wheelbarrow that can make other wheelbarrows". Or "I need to design a motorbike that can ride a motorbike".
As GCDEF said earlier, tell us about the problem you're trying to solve - not about your proposed solution. There's almost certainly a more sensible solution than the one you've asked for.
Or alternatively, if it genuinely does have to be solved this particular way, please explain why. :confused:
One thing I've learned in my years in this profession is that just because somebody thinks they want something doesn't mean it's really what they want or need and the good programmers are the ones that know when they're heading down the wrong path.
Re: exe generates another exe
Quote:
Originally Posted by
GCDEF
One thing I've learned in my years in this profession is that just because somebody thinks they want something doesn't mean it's really what they want or need and the good programmers are the ones that know when they're heading down the wrong path.
A wise man once said, "Question the Spec."
Re: exe generates another exe
can i make an exe with a preinstalled complier?
i give the commands and compiles the code.
Re: exe generates another exe
The example that you gave above simply took some data and sent it to an external stream. But programs need more than data - they need instructions. Instructions typically form the bulk of a programming language.
If you want to use a pre-existing language (such as Java, C++, Pascal or whatever) you should be able to write a program that could call one of the many available compilers and give it a set of instructions to build into a program. But you need to have some kind of instruction language. If you don't have an actual language (and it seems that you probably don't just judging from your example) then you'll have to write an instruction set and a suitable interpreter / compiler / linker etc.
You can't produce a program just from some arbitrary data.
Re: exe generates another exe
some references, john_e?
how can i call a compiler and build a program after some instructions?
Re: exe generates another exe
What programming language will the instructions be in?
Re: exe generates another exe
If I were a gambling man, I'd wager that the OP plans something nefarious with this code. He's way too coy about his requirements.
Re: exe generates another exe
Quote:
Originally Posted by
hoxsiew
If I were a gambling man, I'd wager that the OP plans something nefarious with this code. He's way too coy about his requirements.
I agree.