-
November 8th, 2009, 11:06 AM
#1
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?
-
November 8th, 2009, 11:15 AM
#2
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
-
November 8th, 2009, 11:43 AM
#3
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.
-
November 8th, 2009, 01:00 PM
#4
Re: exe generates another exe
it has to built exactly this way, it has to generate from a piece of code, another exe.
-
November 8th, 2009, 01:18 PM
#5
Re: exe generates another exe
Didn't we cover this in your other thread?
-
November 8th, 2009, 04:57 PM
#6
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
Last edited by Cpp_Noob; November 8th, 2009 at 05:00 PM.
-
November 8th, 2009, 06:02 PM
#7
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.
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
November 8th, 2009, 08:30 PM
#8
Re: exe generates another exe
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.
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.
-
November 9th, 2009, 12:36 AM
#9
Re: exe generates another exe
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."
-
November 9th, 2009, 08:14 AM
#10
Re: exe generates another exe
can i make an exe with a preinstalled complier?
i give the commands and compiles the code.
-
November 9th, 2009, 08:31 AM
#11
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.
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
November 9th, 2009, 08:39 AM
#12
Re: exe generates another exe
some references, john_e?
how can i call a compiler and build a program after some instructions?
-
November 9th, 2009, 09:26 AM
#13
Re: exe generates another exe
What programming language will the instructions be in?
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
November 9th, 2009, 09:29 AM
#14
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.
-
November 9th, 2009, 09:36 AM
#15
Re: exe generates another exe
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|