-=> Propably Rick Arding wrote to All <=-
Hello Rick!
RA> I was wondering what is the right way to pass a structure to a
RA> subroutine. I fiddled and fiddled and the below example works, but it
RA> looks, well redundant.
RA>
RA>
RA> THE STRUCTURE
RA> struct Thing You = {1,1,'\@'};
RA>
RA>
RA> THE CALL TO ShowThing
RA> ShowThing(&You);
RA>
RA> THE FUNCTION
RA> int ShowThing(struct Thing *T)
RA> {
RA> struct Thing TT; /*CAN'T DEAL WITH THE PASSED STRUC*/
RA> TT=*T; /*SO I HAVE TO USE A DUMMY ONE */
RA> gotoxy(TT.Across,TT.Down);
RA> putch(TT.ThingChar);
gotoxy(T->Across, T->Down);
putch(T->ThingChar);
RA> *T=TT;
RA> return(1); /*THEN I COPY THE DUMMY TO *T */
RA>
RA> }
RA>
RA> Is there a more logical way to do this? Sometimes I think C just
RA> isn't worth the effort, with all of its little idiosyncrasies.
I had that proplem myself too.
RA> Thanks
RA> Rick Arding
//
// Sir Robin (jsaksa@tiira.cedunet.com)
// http://www.cedunet.com/~jsaksa/
// DooM-page, programming stuff, music page
//
... Answers: $1, Short: $5, Correct: $25, dumb looks are still free.
--- BBBS/2 v3.33 How-C
---------------
* Origin: Cat-Box - 02-4841086 (2:222/120)
|