2012年5月20日 星期日

C address pointer scope notice

Define:
(A file) : char * tmp
(B  file): function(char *ptr)
             {
                  ptr = open("/tmpfile.txt","w");
             }
--------------------------------------------
(A file)  code:   call (B file)function( tmp )
                        fclose( tmp )            ==> address is null;
             
=============================
the pointer return from open("/tmpfile.txt","w") exist only in (B  file): function(char *address).

沒有留言:

張貼留言