In question https://codereview.stackexchange.com/questions/3917/is-there-anyway-i-can-improve-my-implementation-of-this-c-function at code review I accepted one answer, then a better one came along and I changed it. I earned reputation from both changes putting me at 5 reputation. Is this normal behaviour?
Technically speaking, you accepted answers on two "different" questions. The first one you asked on Stack Overflow which eventually got migrated here and the second you asked here with exactly the same post body. You accepted an answer on one of the questions and accepted an answer on the other. The two distinct accepts on the two "distinct" questions gave you the rep for each. You confused the two for being the exact same question with the exact same set of answers.
Is there anyway I can improve my implementation of this C function (migrated from Stack Overflow)
Is there anyway I can improve my implementation of this C function (your question here)
You can tell they're different by looking at the post id's in the URL and also note the migration message at the bottom:
migrated from stackoverflow.com ...
What should have happened was that either you shouldn't have reposted the same question here and requested a migration. Or if answers were not posted on the question there, delete it and then post it here.
Since there were answers on the question, deleting would not have been possible and a merge would have been more appropriate. You can request a mod to do this by flagging one of your questions and explaining the situation using the "other" option. I've done this so it will probably be a matter of time before this gets done. (it has been merged now)