Reputation: 1085
I'm reading the book The Practice of Programming by Brian W.Kernighan, and I don't quite understand exercise 1-5 in it.
Exercise 1-5. What is wrong with this excerpt?
int read(int *ip) {
scanf("%d", ip);
return *ip;
}
...
insert(&graph[vert], read(&val), read(&ch));
Upvotes: 5
Views: 271
Reputation: 122443
insert(&graph[vert], read(&val), read(&ch));
It's unspecified whether read(&val)
is called first, or read(&ch)
is called first, so you never know which one you are inputting.
Upvotes: 16