Reading strings in C

前端 未结 6 1845
轮回少年
轮回少年 2021-01-14 03:52

If I was using C gets(), and I was reading a string from the user, but I have no idea how big of a buffer I need, and the input could be very large. Is there a way I can det

6条回答
  •  孤独总比滥情好
    2021-01-14 04:16

    Not with gets(). Use fgets() instead.

    You cannot safely get user input with gets().

    You need to use fgets() (or fgetc()) in a loop.

提交回复
热议问题