Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 File Streams
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Justin_




PostPosted: Sat Mar 11, 2006 5:30 pm   Post subject: File Streams

Okay I'm not sure if my question is .NET specific or not, but when I create an output filestream and output strings the begning of each new stream a char that looks like a rectangle appears. I don't know what its called but it looks like a rectangle that is not filled in.

Basically I'd like to not have that rectangle lol. Any suggestions? (supposing you know what I'm talking about)
Sponsor
Sponsor
Sponsor
sponsor
md




PostPosted: Sat Mar 11, 2006 6:06 pm   Post subject: (No subject)

The rectangle would be a character that has no graphical representation. Since you have neglected to post any code it's rather difficult to be able to say why it's getting written.

Really, you've been here long enough to know to post code. Failing to do so is rather poor on your part.
Justin_




PostPosted: Sat Mar 11, 2006 6:23 pm   Post subject: (No subject)

There's nothing exciting about the code. It's exactly as I described, take a look:
c++:

static int Main()
    {
        string nameOfFile = Console.ReadLine();
       

        FileStream fstMembers = new FileStream(nameOfFile, FileMode.Create);
        BinaryWriter wrtMembers = new BinaryWriter(fstMembers);
       

        try
        {
            wrtMembers.Write("James Bloch");
            wrtMembers.Write("Catherina Wallace");
            wrtMembers.Write("Bruce Lamont");
            wrtMembers.Write("Douglas Truth");
        }
        finally
        {
            wrtMembers.Close();
            fstMembers.Close();
        }
        nameOfFile = Console.ReadLine();
        return 0;
    }


I'm guessing its got to do with the way Write handles string streams. Maybe there is a better class to deal with file streams.
wtd




PostPosted: Sat Mar 11, 2006 7:01 pm   Post subject: (No subject)

Is this C++ or C#?
Justin_




PostPosted: Sat Mar 11, 2006 9:57 pm   Post subject: (No subject)

c#
Justin_




PostPosted: Sat Mar 11, 2006 10:47 pm   Post subject: (No subject)

I switched to a different class and it works out. Thanks Cornflake for specifying what that crazy rectangle was. Do you know if it has a name?
rizzix




PostPosted: Sat Mar 11, 2006 11:00 pm   Post subject: (No subject)

wtd wrote:
Is this C++ or C#?


c'mon.. the "finally" keyword should have been a big hint Wink
wtd




PostPosted: Sat Mar 11, 2006 11:32 pm   Post subject: (No subject)

Are you writing text as binary to a file, then expecting it to look fine in a text editor?
Sponsor
Sponsor
Sponsor
sponsor
Justin_




PostPosted: Sat Mar 11, 2006 11:40 pm   Post subject: (No subject)

Correct me if I'm wrong, but isn't all text stored as binary inside a file?
wtd




PostPosted: Sat Mar 11, 2006 11:47 pm   Post subject: (No subject)

Ultimately everything is binary, but if you have an ASCII text file, and write to it as such, the correct line endings will be used. If you have a C# program and run it on Windows, it'll write a carriage return linefeed combo, and on on a *nix it'll write the proper newline for that platform.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: