从文件中读取代码 [英] Reading code from a file

查看:63
本文介绍了从文件中读取代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要做的是创建一个非常基本的A-life模拟器。

我无法弄清楚如何从
读取和执行C ++代码
文件,如果我能做到这一点就可以很容易地制作自定义文件或

让主程序制作它们。

任何帮助都将不胜感激。

What I am trying to do is to create a very basic A-life simulator.
What I can''t figure out is how to read and execute C++ code from a
file, if I could do this it would be simple to make custom files or
have the main program make them.
Any help would be appreciated.

推荐答案

2007年8月21日星期二13:19:22 -0700,mbrigdan写道:
On Tue, 21 Aug 2007 13:19:22 -0700, mbrigdan wrote:

我要做的是创建一个非常基本的A-life模拟器。

我不知道如何从一个读取和执行C ++代码

文件,如果我能做到这一点就可以很容易地制作自定义文件或

让主程序制作它们。

任何帮助都会不胜感激。
What I am trying to do is to create a very basic A-life simulator.
What I can''t figure out is how to read and execute C++ code from a
file, if I could do this it would be simple to make custom files or
have the main program make them.
Any help would be appreciated.



你的意思是用c ++代码加载外部文件并在主应用程序的
内执行它们。那么你需要一个c ++解释器,

或者你必须先编译它们然后再执行。我认为

如果你需要这种功能,你会更好地使用其他更高级的语言。


- -

令人讨厌的用户

You mean load external files with c++ code and execute them within
your main application. Then you either need a c++ interpreter,
or you have to compile them first and then execute. I think
you''re better of with some other higher language if you
need this kind of functionality.

--
Obnoxious User




< mb ****** @ gmail.comwrote in message。 ..

<mb******@gmail.comwrote in message...

我要做的是创建一个非常基本的A-life模拟器。

我无法想象out是如何从

文件中读取和执行C ++代码,如果我能做到这一点,那么制作自定义文件会很简单,或者主程序会生成它们。

任何帮助将不胜感激。
What I am trying to do is to create a very basic A-life simulator.
What I can''t figure out is how to read and execute C++ code from a
file, if I could do this it would be simple to make custom files or
have the main program make them.
Any help would be appreciated.



只需编译它,[检查输出],然后使用''system()''运行它。


[未经测试。只是为了一个想法。 ]

std :: string comp(" g ++");

std :: string cpplibs(" -lmylib");

std :: string cppfile(" MyFile.cpp");

std :: string Command =" \"" + comp + cppfile + cpplibs +" \"" ;;

system(Command);

//在这里查看

系统(MyFile);


获取某些IDE的源代码,并检查它们是如何实现的。


-

Bob R

POVrookie

Just compile it, [check output], and run it using ''system()''.

[ untested. just for an idea. ]
std::string comp( "g++ " );
std::string cpplibs( "-lmylib " );
std::string cppfile( "MyFile.cpp " );
std::string Command = "\"" + comp + cppfile + cpplibs + "\"";
system( Command );
// check it here
system( MyFile );

Get the source for some IDE, and examine how they do it.

--
Bob R
POVrookie


8月21日下午3:39,BobR < removeBadB ... @ worldnet.att.netwrote:
On Aug 21, 3:39 pm, "BobR" <removeBadB...@worldnet.att.netwrote:

< mbrig ... @ gmail.comwrote in message ...
<mbrig...@gmail.comwrote in message...

我要做的是创建一个非常基本的A-life模拟器。

我不知道如何阅读和执行C ++来自

文件的代码,如果我能做到这一点就可以很容易地制作自定义文件或

让主程序制作它们。

任何帮助,将不胜感激。
What I am trying to do is to create a very basic A-life simulator.
What I can''t figure out is how to read and execute C++ code from a
file, if I could do this it would be simple to make custom files or
have the main program make them.
Any help would be appreciated.



只需编译它,[检查输出],然后使用''system()''运行它。


[未经测试。只是为了一个想法。 ]

std :: string comp(" g ++");

std :: string cpplibs(" -lmylib");

std :: string cppfile(" MyFile.cpp");

std :: string Command =" \"" + comp + cppfile + cpplibs +" \"" ;;

system(Command);

//在这里查看

系统(MyFile);


获取某些IDE的源代码,并检查它们是如何实现的。


-

Bob R

POVrookie


Just compile it, [check output], and run it using ''system()''.

[ untested. just for an idea. ]
std::string comp( "g++ " );
std::string cpplibs( "-lmylib " );
std::string cppfile( "MyFile.cpp " );
std::string Command = "\"" + comp + cppfile + cpplibs + "\"";
system( Command );
// check it here
system( MyFile );

Get the source for some IDE, and examine how they do it.

--
Bob R
POVrookie



你能解释一下吗?这可能正是我所需要的。

只是为了清理我需要的东西:


我需要它动态的主程序(在运行时) genarate代码。

我能看到的唯一方法就是(拥有程序)

将其写入文件然后在以后加载。


我需要能够创建和运行大量文件,而不必为每个文件加载机制编码。

Can you explain that a bit more? It might be just what I need.
Just to clear up what I need it for:

I need it the main program to dynamically (At runtime) genarate code.
The only way I can see for this to be done is to (have the program)
write it to a file then load it back at a later time.

I need to be able to create and run a large number of files without
having to code in a loading mechanism for each one.


这篇关于从文件中读取代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆