TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Bret Kellihan
from: Kurt Kuzba
date: 1998-07-18 10:34:28
subject: Fwrite - please help

BK> int AddUser(char UserDatabaseFileName[12], User ToAdd) {
BK>   FILE *stream;
BK>   stream = fopen(UserDatabaseFileName, "ab");
BK>   fwrite(ToAdd, sizeof(ToAdd), 1, stream);
BK>   fclose(stream);
BK>   return 0;
BK> }
BK> The problem is the following error on the fwrite line:
BK> 'fwrite' : cannot convert parameter 1 from 'class ::User' to
BK>   'const void __near *'
   It should work, really. The problem is that you passed a user
   defined type to fwrite() where it expected a pointer.
   You should have sizeof(User) as the second parameter,
   though, and use the address of ToAdd.
fwrite(&ToAdd, sizeof(User), 1, stream);
   Now ToAdd is a given as an address, rather than a defined
   type. fwrite() wants a pointer to work with.

> ] I'm so relieved...  My IQ test came back negative...........

---
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728
SEEN-BY: 639/252 670/213 218
@PATH: 154/750 222 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.