开发者

How to change to an external disk drive in C

Hi all I was wond开发者_如何学Pythonering how (if possible) to change to an external HDD in C. I am writing a program that works with an external HDD.

Thanks much, Mr. Man


Be wary of changing directory within a program - all that's usually needed is to open the files on the external device without actually changing directory to it.

However, on both Windows and Unix, the basic answer is via a 'change directory' operation. On Unix-like platforms, that is the 'chdir(2)' system call; your program should specify the name of the directory where the external hard disk is mounted, and then relative pathnames will write to appropriate locations on the disk (subject to the path name not containing too many "../" sequences).

On Windows, you would need to ensure you specify the drive letter as well as the path on the hard drive.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜