TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CHRISTIAN S. PEDERSEN
from: HERBERT BUSHONG
date: 1997-07-25 04:39:00
subject: Conversion of pointer.

::> Behold, a function which returns a pointer:
The function has a problem though; the variable scope is local to the 
function, 
and whose contents are only "valid" until the function returns. After that,
the memory location may be used for something else... One solution would be 
o
make the variable static.
::> int* test()
::> {
::>     int i=5;
::>     return &i;
::> }
::> Why do I get a "Suspicious pointer conversion"-warning ? The functions 
si
::> this concept seems to work OK. Should I make them differently.
Try parenthesis.
int *test(void)
{
   static int = 5;
   return (&i);
}
#  Herbert Bushong    harchon@centuryinter.net       [TEAM OS/2]    
-  Blackbeard's BBS   Intelec: 239:600/0            
+  Fido: 1:19/19      http://www.intelec.com/software/
---
   RM 1.31 2508   Friday the 13th Part LCMXXIV : Jason Meets Spock
---------------
* 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™.