ZFGC

Resources => Coding => Topic started by: PoeFacedKilla on May 29, 2007, 03:28:26 am

Title: C++ Workin with files
Post by: PoeFacedKilla on May 29, 2007, 03:28:26 am
Is it possible to load code from a .txt file? like if i put cout<<"This is From a File";
it would show that in the program?
Title: Re: C++ Workin with files
Post by: Windy on May 29, 2007, 06:31:22 am
No. At least not without having to create your own parser.
Title: Re: C++ Workin with files
Post by: Infinitus on May 29, 2007, 10:55:14 am
No, thats a features reserved only for scripting languages. With pre-compiled code its next to impossible.
Title: Re: C++ Workin with files
Post by: Venus on May 29, 2007, 07:26:31 pm
You could compile the external source code (in the .txt file for this example) on run time and then load it dynamically. Although that means the user of your program needs to have a compiler installed. And now we are talking about really advanced stuff.

Or, if your .txt-files would only need a limited sets of functions and not too much code (we are not talking about real-time code here, do we?) you can easily make some kind of simple naive parser (e.g. line-by-line each argument separated by space, first argument function-name) for it without that much knowledge on how to write an optimized one.

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved