TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Bo Simonsen
from: Jasen Betts
date: 2003-09-04 07:01:34
subject: Pointers

Hi Bo.

02-Sep-03 22:55:13, Bo Simonsen wrote to Roger


 BS> Hello Roger!

 BS> 02 Sep 03 10:55, Roger Scudder wrote to All:

 RS>> You need to assign the return value from test() to a pointer in
 RS>> main().

 BS> Yes I know, I forgot to write, that i would avoid to use a pointer
 BS> var.. I can make it so it works, but it was just cluefull

 RS>> #include 

 RS>> int main() { char *ptr = NULL;

 RS>> if (NULL == (ptr = test()))

 BS> Quite space-sparing way of writing it.


if ( !(ptr = test()))

 is equivalent, but most compilers warn about assignment in if()s
  NULL==( ... )  stops that warning.

 char *ptr = test();
 if( !ptr )

seems shorter to me

 -=> Bye <=-

---
* Origin: Success is a journey, not a destination. (3:640/1042)
SEEN-BY: 633/267 270
@PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

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