Originally Posted by
frencheneesz
How is it broken? It looks perfectly valid to me, and it works. What do you suggest I do if gets and fgets crash my program?
Your code has no way of checking if it is overflowing the buffer which has been passed into it. You shouldn't use gets for the same reason. Paste an example where fgets is behaving buggily and I can take a look.