fscanf question

This is a discussion on fscanf question within the C Programming forums, part of the General Programming Boards category; is there a way to make fscanf read in a whole string with blanks inlcuded.... i know fscaf ... or ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    84

    fscanf question

    is there a way to make fscanf read in a whole string with blanks inlcuded.... i know fscaf ... or scanf stops when it encounters a blank, is there a way around this? So I can store a sentence?

  2. #2
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712
    Sure, use function fgets!
    Do a little board serch for fgets, and you'll find it
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Or a FAQ search.

    Yes, you can make scanf read entire lines. However, fgets is much better for this sort of thing. The FAQ contains entries on getting a line from the user.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fscanf in different functions for the same file
    By bchan90 in forum C Programming
    Replies: 5
    Last Post: 12-03-2008, 09:31 PM
  2. Quick question about fscanf
    By zyphirr in forum C Programming
    Replies: 16
    Last Post: 11-24-2008, 09:44 PM
  3. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  4. quick fscanf question...
    By Ham in forum C++ Programming
    Replies: 4
    Last Post: 02-01-2003, 08:47 AM
  5. fscanf() question
    By Encrypted in forum C Programming
    Replies: 6
    Last Post: 01-20-2003, 01:14 PM

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