using stdin in fgets

This is a discussion on using stdin in fgets within the C Programming forums, part of the General Programming Boards category; I understand that fgets is better to use than scanf. I am new at using it. Could someone explain what ...

  1. #1
    Unregistered
    Guest

    using stdin in fgets

    I understand that fgets is better to use than scanf. I am new at using it. Could someone explain what the purpose of "stdin" is when you use fgets?

    Example:

    char car [10];
    printf ("\nEnter type of car");
    fgets(car, sizeof(car), stdin);


    Thank you

  2. #2
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    scanf defaults to get data from standard input stream, while fgets lets u specify a stream. In this case, stdin means the standard input stream.

  3. #3
    Unregistered
    Guest
    Thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fgets() from stdin and strcat()
    By rocketman03 in forum C Programming
    Replies: 9
    Last Post: 11-01-2008, 01:31 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. fgets not working after fgetc
    By 1978Corvette in forum C Programming
    Replies: 3
    Last Post: 01-22-2006, 05:33 PM
  4. problem with fgets
    By learninC in forum C Programming
    Replies: 3
    Last Post: 05-19-2005, 08:10 AM
  5. fgets() for stdin not working
    By Yasir_Malik in forum C Programming
    Replies: 2
    Last Post: 03-05-2005, 11:12 AM

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