see this c code.

#include<stdio.h>

void fn (int *ptr)
{
       const int val=100;
       ptr=&val;
}
void fn1(int *ptr)
{
       *ptr = 100;
}

main()
{
       int i=10;
       printf("%d ", i);
       fn(&i);
       printf("%d ", i);
       fn1(&i);
       printf("%d ", i);
}

What is the difference between fn and fn1?
I expected the output to be 10 100 100
but it came as 10 10 100.
can anyone explain what happens in fn.
why 100 in fn is not stored in ptr.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to