Thread: file manager

  1. #16
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    Thanks, it was #include<iterator>, i now get a warning saying:

    Code:
    warning: deleting 'void*' is undefined
    The line in which this warning occurs in is:

    Code:
    delete *i->second;
    ....any ideas about that badboy?

  2. #17
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    IT WORKS!!!!! Don't ask me how i got rid of the the warning, it jus dissapeared. But then i read the introduction to my game into the program and this happened:

    DARN!!!! Can't upload a screenshot, anyways, the writing isn't formatted at all, when it gets to the end of the console line it goes onto a new line, even in the middle of a word! Is there anyway to fix this?

  3. #18
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Widen the length of your console?

  4. #19
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    I've widened it as far as it will go and it still doesn't work, and there is also paragraphs in the text file but they aren't distinguished in the console window. Any ideas?

  5. #20
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Oh. I see your problem... words are getting cut off half way through them? It kinda makes sense. You're probably going to have to format it in your text documents for the width of screen. Unless you want to do some run-time checking... Count the number of letters in a line so far and because you can find out the length of the console window you can '\n' where appropriate.

  6. #21
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    Yeah but on different lines there's a different amound of words, like say the 1st line, it only has 1 word in it, and the second has 2, how am i supposed to format that?

  7. #22
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    I'm not certain I understand. Give me some examples. You'll probably have to write some small background scripting identifiers to identify when one passage is finished. Like getline until you come across a ~ or something. And print up to that:

    Code:
      void read_file( const std::string &filename ) {
        // No error checking done here! Needs to be added
        file_streams[filename] = new std::ifstream(filename.c_str());
        
        std::string line;
    
        while ( std::getline( *file_streams[filename], line ) ) {
          if ( line.find( "~" ) != std::string::npos ) 
            file_contents[filename].at(file_contents[filename].size()) += "\n" + line;
          else
            file_contents[filename].push_back( line );
        }
      }
    file_contents[filename] returns a vector of strings
    using the .at() method for the size of the vector returns the last element of it. You could always have used the [] operator. Both ways return the specific last string.
    += "\n" + line will add the next line to it.

    Now I haven't tested this but I hope it should do the following:

    this is
    a test which
    I haven't tested~
    Does it work?
    Does it work? The ~ has to be at the end of the line. Also you might want to remove it from the line you read.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  2. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  3. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM