www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/27/19:07:22

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Structure ->Structure [?mildly offtopic] and other Newbie Concerns
Date: Wed, 26 Aug 1998 20:02:55 -0300
Organization: NBTel Internet
Lines: 44
Message-ID: <35E4941E.BE3780E1@unb.ca>
References: <19980825 DOT 232445 DOT 3854 DOT 3 DOT matthew DOT krause AT juno DOT com>
NNTP-Posting-Host: fctnts07c01.nbnet.nb.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>         1. How may I copy one structure over another? Example: Given
> default(a struct) and current(a struct of the same type) can a simply say
> current=default? Or is that a BAD thing to do?

    That is fine.  It will just make a binary copy of the data in the struct.

>         2.How may I compare the contents of two structures find out which
> fields differ between them? IE given current and default, I want to know
> that settings.a is different? Is there a way to do to that easier than
> comparing each field?

This should explain it:struct A
{
 int a, b;
 };

int operator == (A& LVal, A& RVal)
{
 return (LVal.a==RVal.a) && (LVal.b==RVal.b);
 }

int main()
{
 A t1,t2;
 t1=t2;
 if(t1==t2) return 1;
 return 0;
 }

>         3.  I know that C and C++ files can be compiled and then linked
> together to form one *.exe file. Is that good form?

    Why not just compile them all as C++ files, there are only very few cases
where C code won't compile correctly as C++ code.

--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT GeoCities DOT com
          Endlis AT nbnet DOT nb DOT ca




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019