Thread: FILE pointer as arguement?

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by @nthony
    the third fscanf argument (a list of pointers) can be ommitted
    No actually you can't. You're thinking of *printf. Well...you can omit the list of arguments, assuming all of your scan codes are actually set to skip conversion. Yours aren't.
    Quote Originally Posted by @nthony
    Also, for thoroughness, I've tried both fscanf and fgets, both resulting in the same error...
    Which is?


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

  2. #17
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    Quote Originally Posted by MDofRockyView
    It depends, for example I don't think that Microsoft wants to write error free code, they want the product to break down after a certain amount of time, so that they can sell you more junk. Another thing is that I agree to test the function call, but I think that the input value can be tested at the appropriate place in the program.
    I honestly think its more a question of rushing that purposely creating bugs. The software engineers are fairly competent, however they are human as well. We all make mistakes and sometimes they can get lost in thousands of lines of code. Some errors are VERY VERY hard to find, and much less fix. If you've written a program with others you should know... rarely do their styles fully complement each other.

    Also, in fscanf, its true the variables are "optional" but thats kinda like using scanf without the optionals there right? Is there any particular reason to be so imprecise?
    Last edited by dpro; 06-29-2006 at 04:57 PM.

  3. #18
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Quote Originally Posted by MDofRockyView
    It depends, for example I don't think that Microsoft wants to write error free code, they want the product to break down after a certain amount of time, so that they can sell you more junk. Another thing is that I agree to test the function call, but I think that the input value can be tested at the appropriate place in the program.
    I don't use Microsoft as my poster child of how to write good code. Don't be lazy and write sloppy code that'll only work in the most stringent of conditions. Yes, you know how your code works, what format the data should be in an how to pass that data for it to work. But will a future user? Chances are, no - users are stupid, and do odd stuff. And when they pass data that isn't up to what you thought it would be - would you rather have accounted for it, and have your program handle it gracefully, even if "gracefully" was an error message informing the user of what went wrong? Or would you rather it core dump / seg fault in his face, causing him to curse at the software you wrote? It's your code; but will it be sloppy or bullet-proof? Sure, you can't predict or handle every problem, but you can cover the minimum of issues.

    Never forget the fifth commandment: "Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest 'foo' someone someday shall type 'supercalifragilisticexpialidocious'."
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  4. #19
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    "Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest 'foo' someone someday shall type 'supercalifragilisticexpialidocious'."
    Code:
    What dost thou type?
    supercalifragilisticexpialidocious
    I shall process...
    and still today the world's first program is still experiencing undefined behavior, and the standard output tablet is still being chiseled. Curs'd be the programmer's head. :P

    That was a stupid joke for something so fun to type.

  5. #20
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by MDofRockyView
    It depends, for example I don't think
    Well you've already proven that...


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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with file pointer in functions
    By willie in forum C Programming
    Replies: 6
    Last Post: 11-23-2008, 01:54 PM
  2. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM