write

A

Art Cummings

Hello all,

does the write function have a return type? I've got a write statement that
isn't writing and I wanted to see if there is a way to do error checking.

Thanks

Art

student.write(reinterpret_cast<char *>(&studentInfo),sizeof(studentInfo));
 
K

Kai-Uwe Bux

Art said:
does the write function have a return type?

The write function from basic_ostream returns a basic_ostream&.

I've got a write statement
that isn't writing and I wanted to see if there is a way to do error
checking.

The returned reference refers to the stream and you could check the flags.

student.write(reinterpret_cast<char *>(&studentInfo),sizeof(studentInfo));

"student" is a rather peculiar name for a stream.



Best

Kai-Uwe Bux
 
R

Rolf Magnus

Art said:
Hello all,

does the write function have a return type?

What write function?
I've got a write statement that isn't writing and I wanted to see if there
is a way to do error checking.

Thanks

Art

student.write(reinterpret_cast<char *>(&studentInfo),sizeof(studentInfo));

What type is student?
 
K

Kai-Uwe Bux

Art said:
student is an arrray of structures

You mean as in:

some_structure student [some_size];

In that case, the line should not compile. There would be no write() member
function.


Best

Kai-Uwe Bux
 
A

Art Cummings

In that case, the line should not compile. There would be no write()
member
function.
Actually it does compile and it writes to disk. The members are populated
as I loop thru the array, and then I write the array of structures to disk.

Thanks
Art
 
J

James Kanze

The write function from basic_ostream returns a basic_ostream&.
The returned reference refers to the stream and you could check the flags.
"student" is a rather peculiar name for a stream.

In addition to the other comments, I'd remind the OP that unless
studentInfo is an array of a character type (char or unsigned
char), ostream::write probably won't do anything useful with it.
(The reinterpret_cast makes me somewhat suspicious, but I've
formatted into arrays of unsigned char on occasion, and used
just such a reinterpret_cast to convert the unsigned char* to
char*. Except that when writing, I'd always cast to "char
const*".)
 
T

terminator

student is an arrray of structures

You mean as in:

some_structure student [some_size];

In that case, the line should not compile. There would be no write() member
function.

Best

Kai-Uwe Bux

a stream can be thougt of as a sequence of records,but I think OP
should give more info.

regards,
FM.
 
K

Kai-Uwe Bux

Art said:
In that case, the line should not compile. There would be no write()
member
function.
Actually it does compile and it writes to disk. [snip]

a) Please post enough context. Keep in mind that news group postings
propagate independently through the net. As a consequence, a reply might
appear on a server before the question. In that case, the thread history
will not be available so you should not rely on that.

b) Here is the line in question:

student.write(reinterpret_cast<char *>(&studentInfo),sizeof(studentInfo));

If that line compiles, it just proves that student is not an array. Could it
be that student is some kind of stream?


Anyway, if you still have a problem with your code, please follow the
recommendations in FAQ clause [5.8].



Best

Kai-Uwe Bux
 
D

Default User

Art said:
Actually it does compile and it writes to disk. The members are
populated as I loop thru the array, and then I write the array of
structures to disk.

Please post a complete, minimal program that demonstrates the problem.




Brian
 
A

Art Cummings

Thanks all, I figured out what I was doing wrong. I'm not posting the
program because it's 7 pages and it can't really be scaled down.

Thanks

Art
 
J

Juha Nieminen

Art said:
Sorry Brian, I forgot, Sometimes you just dash off a quick reply and forget
protocol.

Is it really that hard to configure your news reader to automatically
put the cursor at the end of the quote instead of the beginning? Which
crappy newsreader automatically encourages you to top-post by default?

Besides, quotes should be edited to be minimal (while still preserving
the original idea, of course).
 
A

Art Cummings

Besides, quotes should be edited to be minimal (while still preserving
the original idea, of course).

Not sure what you mean when you say quotes, do you mean the >?

Is it really that hard to configure your news reader to automatically

Juha, i'm using outlook express. Can you tell me how to configure it to put
the cursor at the end?

Thanks

Art
 
A

Alf P. Steinbach

* Art Cummings:
Not sure what you mean when you say quotes, do you mean the >?

Almost: he means the quoted text, whether prefixed with ">" or marked in
some other way.

[snip]
Juha, i'm using outlook express. Can you tell me how to configure it to put
the cursor at the end?

I can't answer exactly what you ask, but if you're using OE you should
as a minimum install OE QuoteFix (google).

Cheers, & hth.,

- Alf
 
T

Tadeusz B. Kopec

Is it really that hard to configure your news reader to automatically
put the cursor at the end of the quote instead of the beginning? Which
crappy newsreader automatically encourages you to top-post by default?

Besides, quotes should be edited to be minimal (while still preserving
the original idea, of course).

I believe Thunderbird is able to show all message headers :p
And for sure it's crappy and encourages to top-post by default. And also
uses variable size fonts so OE users often complain that ascii-art is
broken.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,184
Messages
2,570,979
Members
47,579
Latest member
CharaS3188

Latest Threads

Top