Thread: Determine available drives

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    2

    Determine available drives

    is there any way to determine if there is a disk inserted in a drive( or is it a port ) [sorry for my poor english terms] like in E: or F:, etc.
    i tried doing
    Code:
    FILE *fp;
    fp = fopen( "E:\\text.dbf", "w" );
    if( fp = NULL );
    to test if i can create a file in a disk inserted in E:

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Code:
    if( fp = NULL );
    Well that's not going to do much good unless include a code block after the if statement, and you're assigning, not comparing.
    = means assign.
    == means compare.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Also, are you looking for that specific file, or just to see if there's any drive even there?

    EDIT: Oh hey, you're opening in "w" mode. Right, so check with your OS manufacturer as Salem suggests.
    Last edited by tabstop; 09-05-2009 at 11:51 AM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Sep 2009
    Posts
    2
    Quote Originally Posted by tabstop View Post
    Also, are you looking for that specific file, or just to see if there's any drive even there?
    just to see if there's any drive.

    @cpjust
    oh sorry. it was a typo. i meant == not =

    *EDIT:
    so how do i know if there's any drive inserted?
    Last edited by suomynona; 09-06-2009 at 03:15 AM. Reason: get an answer

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Determine drives attached
    By niqo in forum Windows Programming
    Replies: 2
    Last Post: 10-05-2007, 09:49 AM
  2. determine how many 0's are in a number (value)
    By pyazarian in forum C++ Programming
    Replies: 4
    Last Post: 07-06-2005, 01:20 PM
  3. USB Drives???
    By khpuce in forum Tech Board
    Replies: 14
    Last Post: 12-12-2003, 09:01 AM
  4. installing hard drives and IDE cables...
    By dbaryl in forum Tech Board
    Replies: 14
    Last Post: 09-02-2002, 10:11 AM
  5. Probs with CD drives
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 03-11-2002, 11:09 AM