::> 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)
|