# Thread: does the parameters point to the same nodes??

1. ## does the parameters point to the same nodes??

Code:
item *what1(item *head, item *start, item *end)
{
item *temp;

else{
while(temp->next != start)
temp= temp->next;
temp->next = end;
}
temp = start;
while(start!=end){
start=start->next;
temp->next=end->next;
end->next = temp;
temp=start;
}
}

item *start, *end, *rest_list;

while ((start!=NULL) && (start->next !=NULL)){
if(start->key =='-')
start=start->next;
else{
end=start;
while((end->next!=NULL) &&(end->next->key !='-'))
end=end->next;
rest_list = end->next;
start = rest_list;
}
}
while (end->next !=NULL) end = end->next;
}
i know that *ptr changes in the end of the what1
astrix part of a pointer changes in the end of a function.
so when i call what1,does the parameters point to the same place as before the what1 call,or the parameters change and point to the place in the end of what1
??

2. Code:
int x;
int *p1 = &x, *p2 = &x;

if( p1 == p2 )
{
printf( "They point to the same place.\n" );
}
else
{
printf( "No.\n" );
}
Just like any other value holder, you can compare values to see if they're the same. If the value a pointer holds is the same as another pointer's value, they point to the same place.

Quzah.

to what the parameters will point in the end of what1 calling??
on the one hand they are parameters and in the end
they get their original precalling value.

on the other hand
in a function *ptr are saving their change.
and because every line if changes -> which is *ptr. so its an astrix value
and it has to save the change

??

4. This looks like homework to me.

Function named something like "what1" or "problem1"? Check.
Someone asking what it does? Check.

Why don't you just pass it some information and find out what it's doing if you can't trace it by hand?

Quzah.

5. i am not asking you to solve it
i am saking you about what happens to the parameters

6. Isn't that the same thing?

7. no

to what the parameters will point in the end of what1 calling??
on the one hand they are parameters and in the end
they get their original precalling value.

on the other hand
in a function *ptr are saving their change.
and because every line if changes -> which is *ptr. so its an astrix value
and it has to save the change

??

8. As many threads as we've had about pointers, let's do this one last time: a function can never change the value of something passed to it. Any changes to the value of head, start, and end will not be seen in the original function. (Obviously while the function is still going, you can do whatever you want -- but you are only dealing with a local copy.) Use that information to answer your question.