Sign in to follow this  

reading from a text file

This topic is 4357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to read in character by character from a text file. Now I've done this plenty of times before and know the basics of it but here's the catch. I want to add it to my solution so it compiles with my project. That way no one can see what was in the original file. I just can't think of a good way to read from the file when it's already in there.

Share this post


Link to post
Share on other sites
Quote:
Original post by gellin
I want to read in character by character from a text file. Now I've done this plenty of times before and know the basics of it but here's the catch. I want to add it to my solution so it compiles with my project. That way no one can see what was in the original file. I just can't think of a good way to read from the file when it's already in there.


So you mean you want to add the text file to your project and embed it into a C (or whatever languege) source file so it gets embedded into the application?

If that's what you want, you're going to have to convert your text file into source code and use the text to initialize a string (C string, std::string, Java.string, BSS region, /common/ block, whatever your language is).

Share this post


Link to post
Share on other sites
Quote:
Original post by Bregma
So you mean you want to add the text file to your project and embed it into a C (or whatever languege) source file so it gets embedded into the application?

If that's what you want, you're going to have to convert your text file into source code and use the text to initialize a string (C string, std::string, Java.string, BSS region, /common/ block, whatever your language is).


Yes I want to embed it. I was just hoping there was some way to still read it in like a normal text file without have to convert the file into a string beforehand.

Share this post


Link to post
Share on other sites
If you're using C++ you can use a stringstream and just read like a file from that, but there's not really a lot of point. What has the text file got in it anyway? Anybody with a hex editor will probably be able to dig it out of the EXE without even really knowing the binary format.

Share this post


Link to post
Share on other sites

This topic is 4357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this