Passing filename - as inputted string - to fopen() function

This is a discussion on Passing filename - as inputted string - to fopen() function within the C Programming forums, part of the General Programming Boards category; Originally Posted by rags_to_riches Code: fflush(stdin); <Darth Vader voice>NOOOOOOOOOOOOOOOOOOO!!!!!!!!!!!!!</Darth Vader voice> I'm in love with fflush(stdin). That's just the way ...

  1. #16
    Registered User
    Join Date
    Sep 2008
    Posts
    13
    Quote Originally Posted by rags_to_riches View Post

    I'm in love with fflush(stdin). That's just the way it has to be!


    Edit: In all seriousness...

    How would I go about removing the newline left by my call to fgets() without using fflush(stdin)?

  2. #17
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650

  3. #18
    Registered User
    Join Date
    Sep 2008
    Location
    Nort East of Great Britain!
    Posts
    8
    Quote Originally Posted by laserlight View Post
    What is the error message?

    By the way, filename is a variable length array. Is that intended?
    Not really. I didn't realize it was variable length, that's why I made it as long as the string put in the input buffer using "strlen()". I thought I was being more efficient, but in retrospect its probably rather superfluous

    "IBS" is infact, "Input Buffer Size".

    Is "MAX_PATH" some kind of standard size to store a filename?

    Clint

  4. #19
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by george_1988 View Post
    How would I go about removing the newline left by my call to fgets() without using fflush(stdin)?
    Example:
    Code:
    strtok(whatever_your_buffer_is_called, "\n");

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing an array into a function
    By Ryston in forum C++ Programming
    Replies: 4
    Last Post: 08-29-2006, 05:20 AM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  5. Passing string to function
    By PotitKing in forum C Programming
    Replies: 8
    Last Post: 05-24-2002, 05:17 PM

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