954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Run code from string?

Hello,
i would like to know weather it is possible to run code from a string
e.g

string code = MessageBox.Show("example");
//run the code?
scrypt3r
Junior Poster
114 posts since Aug 2007
Reputation Points: 6
Solved Threads: 2
 

how about system(code.c_str());

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
how about system(code.c_str());

???!! what's it??

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

Yes, what is that

scrypt3r
Junior Poster
114 posts since Aug 2007
Reputation Points: 6
Solved Threads: 2
 

Looks like somebody clicked on the wrong forum. And it would be a nonsensical, wrong answer even if it was in the right forum.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

Write a compiler in your code, feed it the string "example" and it will run.(If your string has no compile errors in it of course)

ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 

Isnt Acient Dragons code in C++?

scrypt3r
Junior Poster
114 posts since Aug 2007
Reputation Points: 6
Solved Threads: 2
 

He means at runtime, right?

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

Yes run code at runtime

scrypt3r
Junior Poster
114 posts since Aug 2007
Reputation Points: 6
Solved Threads: 2
 

Look at this article http://www.codeproject.com/KB/codegen/Run-Time_Code_Generation1.aspx it may help you, or I recommend you to read in whole Microsoft.CSharp and System.CodeDom. namespaces.

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

thanks

scrypt3r
Junior Poster
114 posts since Aug 2007
Reputation Points: 6
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You