TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: RICK ARDING
from: HERBERT BUSHONG
date: 1997-03-25 05:11:00
subject: struct problem

::> int ShowThing(struct Thing *T)
::>     {
::>     struct Thing TT;            /*CAN'T DEAL WITH THE PASSED STRUC*/
::>     TT=*T;                      /*SO I HAVE TO USE A DUMMY ONE    */
no you don't, you passed a pointer to the struct, so use -> to access it's 
members.
::>     gotoxy(TT.Across,TT.Down);
gotoxy(T->Across, T->Down);
::>     putch(TT.ThingChar);
putch(T->ThingChar);
::>     *T=TT;
why copy back. You haven't changed anything.
::>     return(1);                  /*THEN I COPY THE DUMMY TO *T    */
::>     }
::> Is there a more logical way to do this?  Sometimes I think C just isn't
::> worth the effort, with all of its little idiosyncrasies.
Well, you're in the C++ echo, so I'll use C++ to answer. Use a reference,
and since you aren't changing the struct values and make it const.
int ShowThing(const struct Thing &T)
  {
        gotoxy(T.Across, T.Down);
        putch(T.ThingChar);
        return 1;                 
  }
#  Herbert Bushong    harchon@centuryinter.net       [TEAM OS/2]    
-  Blackbeard's BBS   Intelec: 239:600/0            
+  Fido: 1:19/19      http://www.win.net/eunicecity/stltcc/hbush/
---
   RM 1.31 2508   Lawyers: the best argument against gun control...
---------------
* Origin: Blackbeard's BBS - Ville Platte, LA - 318-468-3385 (1:19/19)

SOURCE: echomail via exec-pc

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