<fstream> arghghghhhhhhhh

This is a discussion on <fstream> arghghghhhhhhhh within the C++ Programming forums, part of the General Programming Boards category; Notpad doesn't display it correctly. All non-standard characters are displayed like a box or some other weird symbol that says ...

  1. #16
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Notpad doesn't display it correctly. All non-standard characters are displayed like a box or some other weird symbol that says I don't understand this. Not to mention, Notepad may be a bit more complex than it seems.
    Sent from my iPadŽ

  2. #17
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    So is there a way just to ignore all non-standard characters?
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  3. #18
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Not that I know of.

    ...that's not to say there is no way. Do some research on it.
    Sent from my iPadŽ

  4. #19
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    use get instead and you will be able to get every character. The following will read every character and store it in buffer until EOF or 200 characters have been reached

    Code:
    #include <fstream>
    using namespace std;
    
    void main()
    {
     char buffer[200];
     int index = 0;
    
     ifstream fin;
     fin.open("blbalba.txt");
     while(fin.get(buffer[index++])) if (index == 200) break;
    }
    Last edited by Darryl; 12-01-2005 at 01:04 PM. Reason: spelling

  5. #20
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Hmmm... even non-ascii characters?
    Sent from my iPadŽ

  6. #21
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    Quote Originally Posted by SlyMaelstrom
    Hmmm... even non-ascii characters?
    Do you mean non-printing characters? (Tabs, line-feed, etc) If so, then yes with the exception of I think char(26) (ctrl-z) which gets interpreted as EOF and will stop the while loop. Displaying them is a different matter, but they will be read and stored. For example Carriage Return will be stored as 13

    Or do you mean non-ascii as in Unicode or wide characters, if so it will read them as well, but at 2 chars per letter.


    one other note, you may also be referring to extended ascii, using a signed char will cause them to be stored as negatives, while using unsigned char will allow them to be stored correctly (128 - 255). Again displaying them may be another matter depending on your environment.
    Last edited by Darryl; 12-01-2005 at 01:19 PM.

  7. #22
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Ok, I see what you're saying. Just to remove confusion, I was talking like this: Open a wav file in a text editor and save it as a text document. Try to open that and read it in, right towards the beginning where it defines bitrate and length of the wav file in seconds it gets stuck and stops reading it in. There is something there that it won't take.
    Sent from my iPadŽ

  8. #23
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    It's probably hitting that char(26) I was talking about. The only way to read that is binary. I found that out in an encryption contest I had participated in. The host of the contest had used a substitution cypher using all ascii codes, but I couldn't read in his file cuz it kept hitting that. I verified it with a hex editor and he had to change his algorithm to exclue it.

  9. #24
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    Allright i Quit.
    I managed to find a diffrent way to solve my problem.
    The thing is that, the text file i was talking about was a database of somekind for my project.
    Now i have found *.mdb with the same data, so i'm gonna try to load that...
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  10. #25
    Registered User
    Join Date
    Dec 2005
    Posts
    4

    ASCII Character

    Most MTG programs allow card bodies with carriage returns. If I remember correctly it's (char)13. Load the library into whichever program you use and take a look at 1996 World Champ to see what I mean.

    You have a few options:

    1. Remove every carriage return symbol from your database and lose that functionality.

    2. Load the database until EOF and assign entries as is appropriate (that's what the @'s and ;'s are there for.)

    3. Replace each instance of carriage return with a non-invasive ASCII character (this is probably the simplest, and most do-able option) which you can then set to trigger a carriage return at a more convenient time.

    4. Write your own database.

    If you give up, you suck.
    Last edited by Austaph; 12-01-2005 at 06:20 PM.

  11. #26
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    Now i have found *.mdb with the same data, so i'm gonna try to load that...
    Why should i lose my sanity with this??? symbol of some kind???
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  12. #27
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    Anyway i'm making program for playing MTG online. Are you playing MTG?
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. use <fstream> and ostream overloading together
    By mosu' in forum C++ Programming
    Replies: 3
    Last Post: 08-16-2006, 01:06 PM
  2. <fstream> again !!!!!
    By ElastoManiac in forum C++ Programming
    Replies: 8
    Last Post: 12-19-2005, 02:45 PM
  3. Debug Help w/ <fstream>
    By The Brain in forum C++ Programming
    Replies: 5
    Last Post: 02-14-2005, 04:14 PM
  4. About "fstream" in <fstream.h> and <fstream>
    By L.O.K. in forum C++ Programming
    Replies: 5
    Last Post: 01-08-2005, 05:49 PM
  5. allegro weirdness, <fstream> errors
    By ichijoji in forum Game Programming
    Replies: 2
    Last Post: 02-16-2003, 08:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21