TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: Keith Fowler
date: 1996-03-31 14:41:24
subject: Re: Structures

FA>  KF> typedef unsigned byte char;
FA> The compiler may not like this line, but i do :-) 
FA> It's not needed anyway..                   

    Eheh it was just a typo.. the only reason i put it in was cause i copied 
it from another structure program which had it, but didn't have writing to a 
file :-(

FA>  KF> STRUCT names writenames;
FA>  KF> Will that work?? :-).. any help would be appreciated..
FA> Don't see struct in upper case too often, dunno if it'll compile like that.

    Yeah, i was just outlining what command i used :-)

FA> Oh, and a name into a byte just won't go :-) 
FA> 
FA> struct names{
FA>              char firstname[20];
FA>              char lastname [20];
FA>              };

    Actually, it did work with just byte firstname; dunno how though :-)

FA> struct names{
FA>              char firstname[20];
FA>              char lastname [20];
FA>              };
FA>              
FA>              
FA> struct names writenames;
FA> 
FA> int rite_names()
FA> {
FA>  FILE *outfile;
FA>  outfile = fopen("namefile.dat","wb"); /* make
sure it's opened binary!! */
FA>  if(NULL == outfile) return FALSE;
FA>  fwrite(writenames,sizeof(struct names),1,out);
FA>  fclose (out);
FA>  return TRUE;

    Thanks for this, GREATLY appreciated!...
FA> To read open the file with "rb", and using fread() with
the same parameters
FA> what fwrite() used should work just fine.

    Thanks.. When opening a file with "wb", how come when i print a normal 
string to it ( strcpy(name,"Keith") ) it prints it to the file in
text mode??,
do you need a special string or something??..

    Thanks again.. Cya!

    Keith

--- GEcho 1.00
* Origin: DarkZone BBS, NODE1 V.34+ V.fc HST +61-63-726978 (3:623/683)
SEEN-BY: 50/99 78/0 620/243 623/411 630 631 683 812 711/401 409 410 413 430
SEEN-BY: 711/808 809 932 934 712/515 713/888 714/906 800/1 7877/2809
@PATH: 623/683 630 711/808 809 934

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™.