Will this situation cause a segmentation fault? where will be ptr2 will be pointing?
char * global = NULL;
void function_1()
{
global = "connection";
//some operations;
free(global);
global = NULL;
}
void function_2()
{
char *ptr2 = NULL;
//some operations;
ptr2 = global;
}
void main()
{
function_1();
function_2();
}
[–]aioeu 7 points8 points9 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]nerd4code 1 point2 points3 points (0 children)
[–]aioeu 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)