I not so good at C but I think this is the problem:
You type more than what getchar takes and put in s. the rest needs to be flushed.
edit: Newer mind this I did read it wrong
[I not so good at C but obvious line 29 don't do what we want it to do.
I think the best thing to do is to use the lim value so you newer add to much chars to the s array in the first place.
Your not getting any out of bounds error messages?]