Mail Archives: djgpp/2001/04/20/16:35:30
Message-ID: | <3AE099B3.FE657644@jps.net>
|
From: | Dennis Yelle <dennis51 AT jps DOT net>
|
X-Mailer: | Mozilla 4.75 [en] (Win98; U)
|
X-Accept-Language: | en
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | string can't read certian characters???
|
Lines: | 67
|
Date: | Fri, 20 Apr 2001 13:18:59 -0700
|
NNTP-Posting-Host: | 216.119.20.143
|
X-Complaints-To: | abuse AT onemain DOT com
|
X-Trace: | nntp3.onemain.com 987797594 216.119.20.143 (Fri, 20 Apr 2001 16:13:14 EDT)
|
NNTP-Posting-Date: | Fri, 20 Apr 2001 16:13:14 EDT
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
When I run this program:
-------------------------
#include <cassert>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <string>
unsigned char data[] = {
'd', 0xBC, 0xD2, '\r', '\n',
'e', 0xB2, 0x7B, '\r', '\n',
'd', 0xBC, 0xD2, '\r', '\n',
'e', 0xB2, 0x7B, '\r', '\n',
'f', 0xB2, 0x7B, '\r', '\n'
};
void write_it( char* name)
{
FILE* out = fopen( name, "wb");
assert(out);
int count = 0;
for( unsigned i=0; i<sizeof(data); ++i) {
assert( EOF != fputc( data[i], out));
count++;
}
assert( !fclose( out));
cout << "Wrote " << count
<< " characters to the file " << name << '\n';
}
void read_it( char* name)
{
ifstream in( name);
assert( in);
cout << "Reading....\n";
string s;
for(;in>>s;) {
cout << s.size() << " " << s << '\n';
}
}
int main()
{
write_it( "temp");
read_it( "temp");
return 0;
}
----------------------------
I get this output:
------------------------
Wrote 25 characters to the file temp
Reading....
3 d+-
1 e
--------------------------
So it looks like string input from
a file cannot read some character sequences.
Is this expected and desired behavior?
Or is it a bug?
Dennis Yelle
--
I am a computer programmer and I am looking for a job.
There is a link to my resume here:
http://table.jps.net/~vert/
- Raw text -