A
anonymous
The following program :
#include <stdio.h>
void func ( char * psz )
{
char * sz = "func";
psz = sz;
}
int main()
{
char * psz = "main";
func( psz );
printf ( "\n %s", psz ); return 0;
}
prints 'main'. Is it because a 'copy of' the pointer psz is sent to the
function, also the pointer sz dies after the function - so is it
not wrong to assign it to psz.
#include <stdio.h>
void func ( char * psz )
{
char * sz = "func";
psz = sz;
}
int main()
{
char * psz = "main";
func( psz );
printf ( "\n %s", psz ); return 0;
}
prints 'main'. Is it because a 'copy of' the pointer psz is sent to the
function, also the pointer sz dies after the function - so is it
not wrong to assign it to psz.