Maybe I was not clear but I don't think you understand what I am asking. I know how to load data from a text to a string. The code you've given what that does is load data into a string array, I know that.
What I want is to have the data that was stored in the file after it is loaded to be executed by the compiler or if it can be executed directly from the text without loading it into a string
Are you saying that you want a text file containing C++ code to be read by your program, and then that C++ code to be compiled and executed, all within your running program?
If you're asking what Moschops is guessing, here's my two cents.
For one, there are many different C++ compilers. How you could even attempt to start doing this is dependent on which one you choose.
Second, I really don't think this is a good idea anyways. While I'm not sure what your reasons are, IMO C++ was never designed for this kind of usage and shouldn't be. If you want to have programmable logic on the fly, use some sort of scripting language that can be embedded into your C++ program. For example, Lua scripts can actually be loaded from c-style strings or text files and then be executed by a Lua instance within your own native code.
Something like that. Let me elaborate:
Basically a user would create something an object in the program that would be saved to some external file(in my case a text),whenever the program starts it would load this data from the file and use it to recreate the objects
@Austin J:
I am using Visual Studio 2013, not sure what compiler it uses.
Maybe I'm just asking it wrong I just want to load data from a file to be used within the program.
I'm also asking this done a bit of graphics programming sometime ago involving shaders and i recall that you have to write a separate code for the GPU which is loaded into the program
For your first statement, this depends a lot on what you mean by "objects", but it seems you're asking about making your program more data driven. If the "object" just needs to have data stored, then it's pretty simple. Just write the data to the text file and then read it later. There are lots of learning materials for doing this, although in the end the file format is up to you.
EDIT: I forgot to mention. If the object needs to store behaviour/logic whatever you want to call it, I'd recommend bringing a scripting language into your project.
For your second statement now.
First off, with Visual Studio 2013, you're using the Visual Studio compiler. Microsoft has their own C++ compiler that they release with the IDE.
Secondly...
Indeed in graphics programming there are actually shader languages that can be compiled at runtime. GLSL ( from OpenGL ) and HLSL ( from Direct3D ).
This gets into a pretty big topic actually. Languages such as GLSL constitute what's known as a "programmable graphics pipeline" . You can actually store GLSL code in a hard-coded string, or in a text file. While I haven't used it, I'd imagine HLSL works this way also. These languages are meant to function as little miniature programs called "shaders" and communicate with your GPU for graphics processing purposes.