>I thought its easier that way, no need for malloc or realoc.
Yes, it is easier. The code is shorter, faster, and easier to debug. But if I asked a question that clearly wanted to use dynamic allocation and you told me to use an array, I'd be tempted to smack you.
>I know that, but after all its only a homework
How do you know that the homework doesn't require dynamic allocation?
>I admit never used string input from user in my life
It doesn't have to be user input, you can just as easily redirect from a file and the problems are still there.
>so I don't know whats the problem with gets
What if a line is longer than the buffer that you pass to gets?
>using printf this way causes buffer overflow ???
No, using strlength that way causes buffer overflow. In strlen, this is your loop:
while ( input[count] != '\0' )
If the first character in the string is '\0' then there's not a problem, but because it's extremely difficult and unlikely for a user to actually have getchar return 0, that first character will not be '\0' unless you explicitly set it as such, which you don't. Therefore, the loop will walk all over memory that you don't own, and that's a buffer overflow.
>But i have modifed the prog a bit and its workin for strings.
Just because it works doesn't mean it's correct. Your modified program has all of the same problems we've already pointed out to you. I suggest you try to understand what's going on rather than just change code until it appears to work.