How to read from input until newline is found using scanf()?

后端 未结 8 1617
野性不改
野性不改 2020-11-30 05:58

I was asked to do a work in C when I\'m supposed to read from input until there\'s a space and then until the user presses enter. If I do this:

scanf(\"%2000         


        
8条回答
  •  -上瘾入骨i
    2020-11-30 06:46

    Sounds like a homework problem. scanf() is the wrong function to use for the problem. I'd recommend getchar() or getch().

    Note: I'm purposefully not solving the problem since this seems like homework, instead just pointing you in the right direction.

提交回复
热议问题