How can I read a paragraph in via the terminal as a single string in C?

前端 未结 3 956
说谎
说谎 2021-01-21 10:27

I\'m writing a C program that should read in an essay from a user. The essay is divided into multiple paragraphs. I don\'t know how many lines or characters the essay will be,

3条回答
  •  抹茶落季
    2021-01-21 11:01

    You can read character at a time and copy it into your essay buffer. When your essay buffer runs out of space, you can do a realloc to get another chunk of memory. When your character that you read is a "#" you're done.

提交回复
热议问题