![]() |
|
#1
|
||||
|
||||
current drive number?I would like to find current drive number...There was a function called getdisk() and setdisk() in <dir.h>...but it doesn't seem to work in new compilers...Is there any other function?
__________________
Gravitation is not responsible for people falling in love. -Albert Einstein |
|
#2
|
|||
|
|||
Re: current drive number?Quote:
The C language and Standard C libraries (C++ also) are deliberately ignorant of file organization. Therefore, since functions about disk drives are necessarily implementation-dependent, you have to tell us: What operating system? What compiler? Maybe someone with the same setup as you can give you the information or a link to some reference. Regards, Dave |
|
#3
|
||||
|
||||
Re: current drive number?Windows 2000 Professional
Using both VC++6.0 & DEV C++ IDE __________________
Gravitation is not responsible for people falling in love. -Albert Einstein |
|
#4
|
|||
|
|||
Re: current drive number?Quote:
There is a function, getcwd(), that is present in some systems that retrieves the entire path to the current working directory. Since it is not a standard C library function, it is possible that not all systems have this function and for systems that have it, its prototype may not be in the same header file. Compile the following program with VCC++6.0 (also works for Borland bcc32): CPP / C++ / C Code:
This also works with dev-c, but you might want to put the usual system("PAUSE") before the return 0; if you run it from the IDE. (and #include <stdlib.h> if you do this). Or use whatever you usually use to keep the window from closing upon termination (getchar() or whatever). Cygwin gcc users don't have <direct.h>, but can find the prototype for getcwd() in <unistd.h> . Note that getcwd() returns the entire path to the current working directory (the directory from which the program was invoked). Borland, Microsoft, and dev-c++ users can get the disk drive letter from the start of the path. Regards, Dave |
|
#5
|
||||
|
||||
Re: current drive number?Quote:
Dave!!! How could you?!?!?! I thought you knew better. See this.By the way, alcoholic, have you checked MSDN? What you want is there and I believe it's a relatively obvious name. __________________
Age is unimportant -- except in cheese |
|
#6
|
||||
|
||||
Re: current drive number?Walt, I guess Visual C++ automatically puts system("PAUSE") at the end of each program, so that "Press any key to continue.." appears.
What do you think? Well. I am not sure about this. Just a thought. Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#7
|
||||
|
||||
Re: current drive number?Quote:
__________________
Age is unimportant -- except in cheese |
|
#8
|
|||
|
|||
Re: current drive number?if you mean Dev-C++, not added there.
|
|
#9
|
|||
|
|||
Re: current drive number?Quote:
Everybody is entitled to his/her opinion, and I respect yours and all of the other system("PAUSE") commandos. However, with dev-c++, (and, maybe, other IDEs as well), default console applications are built with system("PAUSE") just before the end of main() so that command line applications can be run from the IDE and the window will stay open until the user hits a key. The system() function is a part of the C Standard Library and always has been. What happens when you invoke a program like "PAUSE" is obviously system-dependent (and won't work everywhere). If people aren't using dev-c++, and if their system doesn't have a "PAUSE" command, the system will complain at run time and the user can figure out what to do (or ask somebody). For beginners, I see no reason to make them do extra work to subvert the default behavior of their particular IDE just because of my opinion. I, personally, never use system("PAUSE"). Note that nowhere in my program (or any other program that I have ever posted) to I use system("PAUSE"). On the other hand, I like to post things that work. If a user copied my program into a file in a dev-c++ project, it would work, but the window would close immediately (before the user had time to read the results). Then we would have got some inquiries concerning "how to keep the window open when running from the dev-c++ IDE". (Or, maybe, not. Anyhow, this way the answer is already there in case people actually read this stuff.) On the other hand, checking with MSDN is guaranteed to give system-dependent functions (and lots of void main() examples that we all hate so much --- and it can be argued that void main() does violate C/C++ Standards). So: how can you excoriate a person for suggesting that it might be OK to use a standard library function in a way that is the default behavior for projects created by an IDE "wizard" (the Original Poster said that he was using dev-c++) while at the same time recommending a reference that has lots of useful information, but is pretty much guaranteed not to have standards-compliant solutions? (I use MSDN all of the time when looking for information about Windows programs and interfaces, which of course is systems-dependent by definition. I still shudder at all of the void main() examples.) I would rather have beginners produce a program that executes according to their expectations and not be distracted by having people tell them about a lot of stylistic opinions that will not result in any improvement or fix any bugs in their programs. Style is important to me, as I have mentioned a few times (a lot of times, actually --- sometimes I get quite emotional about style), but insisting that others use my opinions as the basis for their programs is not where I'm at. Your Mileage May Vary. Regards, Dave "A foolish consistency is the hobgoblin of little minds." ---Ralph Waldo Emerson an essay on "Self-Reliance" Last edited by davekw7x : 06-Jan-2006 at 13:54.
|
|
#10
|
|||||
|
|||||
Re: current drive number?Quote:
Quote:
Quote:
You shudder, I cringe. Quote:
Quote:
My 2 dracmas... Well probably 4. "Just because it can be done doesn't mean it should be done" -- Barry Glasford (among others I'm sure) __________________
Age is unimportant -- except in cheese |
Recent GIDBlog
Developing GUIs with wxPython (Part 4) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Binary number systems: BCD, twos complement, ones complement, etc. | machinated | Miscellaneous Programming Forum | 6 | 08-Feb-2006 10:51 |
| Knights Tour - Reloaded . | kobi_hikri | C Programming Language | 12 | 03-Oct-2005 12:15 |
| linked list error message | Krandygrl00 | C++ Forum | 4 | 22-Jun-2005 14:13 |
| Linked Lists | DCOM | C Programming Language | 4 | 27-Mar-2005 00:00 |
| Anyone can write a program code for this??? | chriskan76 | C Programming Language | 1 | 19-Oct-2004 20:25 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The