Accepting input from keyboard

This is a discussion on Accepting input from keyboard within the C Programming forums, part of the General Programming Boards category; I was looking around how to accept input from the keyboard,and I read that certain functions like getchar,gets or scanf ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    23

    Accepting input from keyboard

    I was looking around how to accept input from the keyboard,and I read that certain functions like getchar,gets or scanf are good for small programs to teach you a basic overview on programming,but then they also state that they aren't a very good choice,and there are better ways to do it.

    What I'm asking is what are those ways?

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    Quote Originally Posted by 7h3_0r4c1_3 View Post
    I was looking around how to accept input from the keyboard,and I read that certain functions like getchar,gets or scanf are good for small programs to teach you a basic overview on programming,but then they also state that they aren't a very good choice,and there are better ways to do it.

    What I'm asking is what are those ways?
    Using a fgets / sscanf pair is generally considered an efficient method.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code not accepting input for first string
    By suryak in forum C Programming
    Replies: 11
    Last Post: 07-05-2011, 01:03 PM
  2. Accepting formatted input
    By fxtdr79 in forum C Programming
    Replies: 15
    Last Post: 06-28-2010, 01:25 PM
  3. Problems with fgets not accepting input from stdin
    By k2712 in forum C Programming
    Replies: 7
    Last Post: 08-25-2007, 11:33 PM
  4. Accepting Multiple Types of Input
    By Junior89 in forum C++ Programming
    Replies: 2
    Last Post: 03-07-2006, 10:25 PM
  5. accepting input while writing to screen
    By variable in forum C Programming
    Replies: 17
    Last Post: 02-06-2005, 09:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21