Thread: Need an advice

  1. #1
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669

    Lightbulb Need an advice

    Hi!

    I need an advice about the error checking for files. I'm writing a BIG project and I'm checking some values inside the setup file.

    Now I'm asking you guys what would be better.

    If I check the file, if it is not NULL when opened, at the start of the program or I check the file everytime it is opened and checked for the values?
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    assuming it's a setup file, it's probably relatively small. you could load it into memory and avoid the whole problem. just check once.

  3. #3
    Registered User alpha561's Avatar
    Join Date
    May 2002
    Posts
    18
    Well if you were going to write to the file (I'm assuming you will at some stage), you should always check to see if the file is NULL. If the file was NULL, obviously it wouldn't contain any data. If it isn't NULL, then you would just need to read in the values.
    alpha561

    "You don't want to sell me death sticks"

  4. #4
    Registered User alpha561's Avatar
    Join Date
    May 2002
    Posts
    18
    (Can't seem to edit the above posts for some reason)...

    What I meant was that when dealing with files (reading or writing to them) you should always check to see if the file is NULL. Again, as I said before, if the file was NULL, obviously it wouldn't contain any data. If it isn't NULL, then you would just need to read in the values. I would say, only check once, at the very start.
    Last edited by alpha561; 05-23-2002 at 11:34 PM.
    alpha561

    "You don't want to sell me death sticks"

  5. #5
    Registered User stautze's Avatar
    Join Date
    Apr 2002
    Posts
    195
    To check if the file is NULL is only one line if code. So why not be safe. That way you would never have to worry about it. I would even go as far as to say you can never have too much error checking. People are idiots, and god knows what someone can do to your program. That is my opinion.
    'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition

  6. #6
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    ALWAYS CHECK RETURN VALUES !!!

  7. #7
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669

    Thumbs up

    Ok, I will always check the return values .
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advice on C Programming with MSVC++ 2008
    By IT_Guy in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2009, 04:23 AM
  2. Advice on multithreading
    By Calef13 in forum C++ Programming
    Replies: 3
    Last Post: 08-24-2007, 03:28 PM
  3. girl friend advice (prob. the wrong place)
    By B0bDole in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 10-22-2004, 06:38 PM
  4. need advice on project
    By lambs4 in forum C Programming
    Replies: 2
    Last Post: 07-23-2003, 01:06 PM
  5. Who's telling the truth??? Career Advice Needed Badly
    By Ican'tCjax,fl in forum C Programming
    Replies: 1
    Last Post: 11-06-2002, 06:16 PM