![]() |
code in variable
would it work if i put a code in a string and then just placed the string by itself like this:
:
thisisastring = printf("hello world");yeah i know the coding is bad but im in a lil bit of a hurry cuz im leaving in a few minutes so i didnt have the time to write something but would that work? if not does any one have an alternative method of doing something like this? |
Nope. I'd say more, but I'm in a bit of a hurry.
|
lol alright ill explain a lil more seen as i just saved myself a bit of time and i notice sum sarcasm in the air but what i want to do is allow the user to type in a code and have the computer run it
like say the user inputted: :
printf("hello, how are you?");could i have the code saved and run later so that the program actually outputs "hello, how are you?" on the screen |
Sounds like you'd want to save the code to a file entered and later compile the file with a compiler.
|
Quote:
|
This sounds like a job for an embedded scripting language like Lua. Here's a quick tutorial on how to embed Lua in C.
|
It wouldn't work the way you tried to make it work. I didn't know you could do this, but if you have a code which saves thisisastring as a printf statement, and then you use another printf statement and print out the variable thisisastring - it will print out hello world followed by a few integers. not sure why, maybe someone else can explain.
|
so..............
you want a user to enter data, then you will send it to stdout at a later time? what are you trying to do? you could cin>>some stuff then sleep() for awhile, then cout<<their bullshit; this sounds weird. please say exactly what you're trying to do. |
It sounds like the OP is trying to write an interpreter. That would work for an interpreted language but it would be perhaps less than trivial to do for compiled languages.
|
Or he's trying to write shellcode....
|
| All times are GMT -5. The time now is 1:50 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC