Capturing a variable length string from the command-line in C

后端 未结 4 1617
耶瑟儿~
耶瑟儿~ 2021-01-16 06:03

I\'ve looked everywhere for an answer to my question, but I have yet to find a solid answer to my problem.

I\'m currently in the process of writing a program in C, s

4条回答
  •  自闭症患者
    2021-01-16 06:31

    Use getline(3) if you really need. It's POSIX.1-2008. And be aware that unlimited length lines are an easy attack vector for DOS-attacks (OOM). So consider making up a reasonable line length limit, and using fgets(3).

提交回复
热议问题