Newbie IO questions

This is a discussion on Newbie IO questions within the C Programming forums, part of the General Programming Boards category; Hi! 1) What is the difference between these two functions: Code: fscan( stdin , %d, integer ); scanf( %d , ...

  1. #1
    Disturbed Boy gustavosserra's Avatar
    Join Date
    Apr 2003
    Posts
    244

    Newbie IO questions

    Hi!
    1) What is the difference between these two functions:
    Code:
       fscan( stdin , %d, integer );
     
       scanf( %d , &integer );
    I know that fscanf is used to read files, but I see a lot of fscanf in books, just to read from the stdin. Isn't better use scanf, once that is smaller?

    2) How can I simulate an EOF from the console? Supposing that I want to make a program that can read from the console or a file?

    Thanks for all replys!!
    Nothing more to tell about me...
    Happy day =)

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    1) Provided the calls are correct:
    Code:
    fscanf(stdin, "%d", &integer);
    scanf("%d", &integer);
    There's no difference. fscanf is more generic than scanf as it can read from any input stream. scanf is restricted to stdin except when stdin is redirected.

    2) For the most part, DOS and Windows systems use the ctrl+z keyboard combination to flag EOF on the console, *nix systems typically use ctrl+d.
    My best code is written with the delete key.

  3. #3
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    This computer lets me use both CTRL+C and CTR+Z, I'm on win ME

  4. #4
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    Originally posted by Draco
    This computer lets me use both CTRL+C and CTR+Z, I'm on win ME
    Ctrl-C doesn't send EOF. it sends TERM.

  5. #5
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    ah..I see........I was unaware. Well, now for the obvoius follow up...what is TERM?

  6. #6
    Disturbed Boy gustavosserra's Avatar
    Join Date
    Apr 2003
    Posts
    244
    Thaks you all!
    Nothing more to tell about me...
    Happy day =)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. newbie questions
    By raptorx in forum C Programming
    Replies: 2
    Last Post: 10-10-2007, 10:30 PM
  2. more newbie questions - file io
    By sunzoner in forum C++ Programming
    Replies: 1
    Last Post: 06-13-2002, 05:33 AM
  3. Barrage Of Questions...Theory impossible? File IO on Web Domain?
    By MagiZedd in forum Windows Programming
    Replies: 0
    Last Post: 10-24-2001, 09:13 PM
  4. Episode II Return Of the newbie : Website IO Question
    By MagiZedd in forum Windows Programming
    Replies: 1
    Last Post: 10-18-2001, 09:58 PM
  5. Real newbie with VC6 questions
    By MagiZedd in forum Windows Programming
    Replies: 8
    Last Post: 10-15-2001, 09:27 PM

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