Thread: scanf() input question

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    3

    scanf() input question

    Is there any way to obtain all characters of input from a line until the user presses the return key? i have tried
    Code:
    scanf("%99s", string)
    which still only takes input from one "word" until the next whitespace character. I have also tried
    Code:
    scanf("%99c", string)
    which does indeed take 99 characters, but will badger the user to enter more characters until it has completely satisfied the requirement.

    any help would be appreciated, thanks.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You should read the manual on scanf, particularly where it says "[".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. input using scanf()
    By kizyle502 in forum C Programming
    Replies: 5
    Last Post: 09-10-2009, 12:56 AM
  2. getchar won't take any input after scanf
    By pshirishreddy in forum C Programming
    Replies: 2
    Last Post: 08-02-2009, 11:46 AM
  3. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  4. scanf question
    By panfilero in forum C Programming
    Replies: 1
    Last Post: 11-21-2005, 07:22 AM
  5. cin.getline question (user's input too long)
    By JerryL_MB in forum C++ Programming
    Replies: 1
    Last Post: 12-09-2002, 12:17 PM