delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/07/21:28:06

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: struct...help?
Date: Mon, 07 Sep 1998 19:24:29 -0300
Organization: NBTel Internet
Lines: 24
Message-ID: <35F45D1D.5D2FF629@unb.ca>
References: <3 DOT 0 DOT 5 DOT 16 DOT 19980906220313 DOT 0cf77836 AT mail DOT tir DOT com> <35F3447B DOT 4576EC37 AT alcyone DOT com>
NNTP-Posting-Host: fctnts05c61.nbnet.nb.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Erik Max Francis wrote:
> In C you can only do this on _initialization_, not general assignment.
> That is, you can use the structure initialization syntax when the
> structure is defined, but no time after that.
	That is technically true, but there is a way around that.  You can initialize
an unnamed instance of the structure and then copy it to yours:

struct Mine {
 int a,b,c;
 };

Mine a;
a = (Mine){4,2,0};

> Further, the structure initializers must all be constant.
	That is true for ANSI, but not for DJGPP.  You can use variables in DJGPP.

-- 
     (\/) 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