TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Roger
from: Bo Simonsen
date: 2003-09-02 22:55:12
subject: Pointers

Hello Roger!

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().

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

 RS> #include 

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

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

Quite space-sparing way of writing it.

 RS>         {
 RS>                 fprintf(stderr, "%s\n", "The test
function returned
 RS> NULL");
 RS>                 return EXIT_FAILURE;
 RS>         }

 RS>         printf("%s", ptr);

 RS>         /* it is now safe to free the block */

 RS>         free(ptr);

 RS>         return EXIT_SUCCESS;
 RS> }


Looks like a good solution, thanks! :)

Regards,
Bo

--- GoldED+/LNX 1.1.5
* Origin: The Night Express, Roennede Dk (2:236/100)
SEEN-BY: 633/267 270
@PATH: 236/100 237/9 20/11 106/1 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™.