I have a linked list and a setter function.
struct my_struct {
int value;
int type;
char *name;
struct my_struct *next;
};
struct my_struct *setValue(struct my_struct *s, char *name, int b) {
if(s!=NULL) {
while(s != NULL) {
if( strcmp(s->name,name) == 0) {
s->value = b;
}
s=s->next;
}
return s;
}
return NULL;
}
Here, name is the search keyword and b is new value of s->value. Why s->value cannot change? After that function, the output is weird. I can't understand, what happened.