| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"Art Cummings" |
| Date: |
06 Dec 2007 09:00:12 PM |
| Object: |
write |
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));
.
|
|
| User: "Rolf Magnus" |
|
| Title: Re: write |
07 Dec 2007 03:53:15 AM |
|
|
Art Cummings wrote:
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?
.
|
|
|
| User: "Art Cummings" |
|
| Title: Re: write |
07 Dec 2007 07:58:14 AM |
|
|
student.write(reinterpret_cast<char
*>(&studentInfo),sizeof(studentInfo));
What type is student?
student is an arrray of structures
Art
.
|
|
|
| User: "Kai-Uwe Bux" |
|
| Title: Re: write |
07 Dec 2007 08:40:15 AM |
|
|
Art Cummings wrote:
student.write(reinterpret_cast<char
*>(&studentInfo),sizeof(studentInfo));
What type is student?
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
.
|
|
|
| User: "Art Cummings" |
|
| Title: Re: write |
07 Dec 2007 10:02:37 AM |
|
|
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
.
|
|
|
| User: "Default User" |
|
| Title: Re: write |
07 Dec 2007 01:05:48 PM |
|
|
Art Cummings wrote:
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.
Please post a complete, minimal program that demonstrates the problem.
Brian
.
|
|
|
| User: "Art Cummings" |
|
| Title: Re: write |
07 Dec 2007 03:40:29 PM |
|
|
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
"Default User" <defaultuserbr@yahoo.com> wrote in message
news:5rtjscF16af8hU1@mid.individual.net...
Art Cummings wrote:
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.
Please post a complete, minimal program that demonstrates the problem.
Brian
.
|
|
|
| User: "Default User" |
|
| Title: Re: write |
07 Dec 2007 07:13:01 PM |
|
|
Art Cummings wrote:
Thanks all, I figured out what I was doing wrong.
Top-posting again, I see. Why?
Brian
.
|
|
|
| User: "Art Cummings" |
|
| Title: Re: write |
07 Dec 2007 08:35:16 PM |
|
|
"Default User" <defaultuserbr@yahoo.com> wrote in message
news:5ru9ctF16pfilU1@mid.individual.net...
Art Cummings wrote:
Thanks all, I figured out what I was doing wrong.
Top-posting again, I see. Why?
Brian
Sorry Brian, I forgot, Sometimes you just dash off a quick reply and forget
protocol.
Art
.
|
|
|
| User: "Juha Nieminen" |
|
| Title: Re: write |
07 Dec 2007 08:52:34 PM |
|
|
Art Cummings wrote:
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).
.
|
|
|
| User: "Art Cummings" |
|
| Title: Re: write |
07 Dec 2007 10:42:38 PM |
|
|
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
.
|
|
|
| User: "Alf P. Steinbach" |
|
| Title: Re: write |
07 Dec 2007 11:29:06 PM |
|
|
* 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 >?
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
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
.
|
|
|
|
|
| User: "Tadeusz B. Kopec" |
|
| Title: Re: write |
08 Dec 2007 06:12:28 AM |
|
|
On Sat, 08 Dec 2007 04:52:34 +0200, Juha Nieminen wrote:
Art Cummings wrote:
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).
I believe Thunderbird is able to show all message headers :-P
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
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.
--
Tadeusz B. Kopec (tkopec@NOSPAMPLEASElife.pl)
Put cats in the coffee and mice in the tea!
.
|
|
|
|
|
|
|
|
|
| User: "Kai-Uwe Bux" |
|
| Title: Re: write |
07 Dec 2007 10:52:42 AM |
|
|
Art Cummings wrote:
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
.
|
|
|
|
|
| User: "terminator" |
|
| Title: Re: write |
07 Dec 2007 10:35:35 AM |
|
|
On Dec 7, 5:40 pm, Kai-Uwe Bux <jkherci...@gmx.net> wrote:
Art Cummings wrote:
student.write(reinterpret_cast<char
*>(&studentInfo),sizeof(studentInfo));
What type is student?
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.
.
|
|
|
|
|
|
|
| User: "Kai-Uwe Bux" |
|
| Title: Re: write |
07 Dec 2007 03:46:12 AM |
|
|
Art Cummings wrote:
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
.
|
|
|
| User: "James Kanze" |
|
| Title: Re: write |
07 Dec 2007 10:04:02 AM |
|
|
On Dec 7, 10:46 am, Kai-Uwe Bux <jkherci...@gmx.net> wrote:
Art Cummings wrote:
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.
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*".)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34
.
|
|
|
|
|

|
Related Articles |
|
|