Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 8th, 2007, 5:56 PM   #1
fightthecool
Newbie
 
Join Date: Feb 2007
Posts: 3
Rep Power: 0 fightthecool is on a distinguished road
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?
fightthecool is offline   Reply With Quote
Old Feb 8th, 2007, 6:01 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Feb 8th, 2007, 6:10 PM   #3
fightthecool
Newbie
 
Join Date: Feb 2007
Posts: 3
Rep Power: 0 fightthecool is on a distinguished road
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
fightthecool is offline   Reply With Quote
Old Feb 8th, 2007, 6:14 PM   #4
Eoin
Hobbyist Programmer
 
Eoin's Avatar
 
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3 Eoin is on a distinguished road
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.
Eoin is offline   Reply With Quote
Old Feb 8th, 2007, 6:31 PM   #5
fightthecool
Newbie
 
Join Date: Feb 2007
Posts: 3
Rep Power: 0 fightthecool is on a distinguished road
Quote:
you'd want to save the code to a file entered and later compile the file with a compiler.
oh alright i was afraid of that
fightthecool is offline   Reply With Quote
Old Feb 8th, 2007, 7:13 PM   #6
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
This sounds like a job for an embedded scripting language like Lua. Here's a quick tutorial on how to embed Lua in C.
Arevos is offline   Reply With Quote
Old Feb 8th, 2007, 9:52 PM   #7
Fall Back Son
Professional Programmer
 
Join Date: Oct 2006
Posts: 257
Rep Power: 2 Fall Back Son is on a distinguished road
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.
Fall Back Son is offline   Reply With Quote
Old Feb 9th, 2007, 2:34 AM   #8
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
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.
bl00dninja is offline   Reply With Quote
Old Feb 9th, 2007, 3:36 AM   #9
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3 Jimbo is on a distinguished road
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>
Jimbo is offline   Reply With Quote
Old Feb 9th, 2007, 3:34 PM   #10
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
Or he's trying to write shellcode....
jim mcnamara is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:56 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC