|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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)); |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
>>
>> student.write(reinterpret_cast<char >> *>(&studentInfo),sizeof(studentInfo)); > > What type is student? > student is an arrray of structures Art |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
> > 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 |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
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ée objet/ Beratung in objektorientierter Datenverarbeitung 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34 |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
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. |
|
![]() |
| Outils de la discussion | |
|
|