![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2007
Posts: 3
Rep Power: 0
![]() |
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");
thisisastring;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? |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Nope. I'd say more, but I'm in a bit of a hurry.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Feb 2007
Posts: 3
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3
![]() |
Sounds like you'd want to save the code to a file entered and later compile the file with a compiler.
__________________
Visit my website BinaryNotions. |
|
|
|
|
|
#5 | |
|
Newbie
Join Date: Feb 2007
Posts: 3
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
This sounds like a job for an embedded scripting language like Lua. Here's a quick tutorial on how to embed Lua in C.
|
|
|
|
|
|
#7 |
|
Professional Programmer
Join Date: Oct 2006
Posts: 257
Rep Power: 2
![]() |
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.
|
|
|
|
|
|
#8 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
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.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#9 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
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.
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
#10 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
Or he's trying to write shellcode....
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| EXECryptor software protection | Jean5 | C++ | 35 | Oct 10th, 2006 7:10 PM |
| Compiling Maverik 6.2 (from C) | megamind5005 | C | 16 | May 3rd, 2006 5:41 PM |
| Code is changing a variable that isn't involved | davidguygc | C++ | 4 | Dec 7th, 2005 8:45 PM |
| How to post a question | nnxion | C | 0 | Jun 3rd, 2005 8:55 AM |
| Pointers in C (Part I) | Stack Overflow | C | 4 | Apr 28th, 2005 7:03 PM |