Thread: text question

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    6

    text question

    lets say i write a block of text in a notpad file, multiple otepad files, is there a way i make my program open it and import the text.. or is it better to just put the text directly in the code???

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    If you are under windows and don't care much about portability you can use CreateFile(), GetFileSize() and ReadFile(). This will get you the whole text, given that you have access to enough memory to buffer the text. If you care about portability, you can use an std::ifstream object.

    Edit: I was slightly off-topic. Putting the text in your code will only make your code harder to read and longer uselessly. If you have a lot of text to load and it is causing your application to slow down when loading text, you can create a separate thread to load the text.

  3. #3
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Or you could go with the completely crazy idea and learn File I/O. There are even tutorials on the site, I hear.

  4. #4
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Quote Originally Posted by citizen
    Or you could go with the completely crazy idea and learn File I/O. There are even tutorials on the site, I hear.
    You can do that? Wow. Gee, you're right! I found one here, and another one here (very end of post), where I was trying to explain it to someone. Egad, who'd have thunk it?
    Last edited by twomers; 05-24-2006 at 01:32 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Curious text performance question...
    By Raigne in forum Game Programming
    Replies: 4
    Last Post: 02-07-2008, 09:14 PM
  2. question about comparing text in a file...
    By laar in forum C++ Programming
    Replies: 12
    Last Post: 03-19-2006, 02:03 PM
  3. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 03:17 PM
  4. Replies: 3
    Last Post: 05-25-2005, 01:50 PM
  5. quick question about C Dos text menu pgm i was doing
    By Shadow in forum C Programming
    Replies: 2
    Last Post: 09-16-2001, 10:26 AM