打开文件中使用C另一个目录 [英] Opening file in another directory in C

查看:139
本文介绍了打开文件中使用C另一个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是如何实现的呢?我想用

  PFILE = FOPEN(文件,RB);

在哪里文件是一个字符,字符串或含长到包含二进制文件的本地路径文字文本

  C:\\ Documents和Settings \\ Supernovah \\桌面\\ Supernovah.bin

但当然是崩溃的。

我也有兴趣在如何在当前目录复发在一个便携的方式。 WINDOWS.H是有点难看,但如果我不能在一个可移植的方式做到这一点。就这样吧。

感谢:)


解决方案

 的char *文件=C:\\\\ Documents和Settings \\\\ \\\\ Supernovah桌面\\\\ Supernovah.bin ;
FILE * PFILE = FOPEN(文件,RB);

How is this achieved? I want to use

pFile = fopen( file, "rb" );

Where file is a char, string or long containing the literal text containing a local path to a binary file

C:\Documents and Settings\Supernovah\Desktop\Supernovah.bin

but of course that crashes.

I am also interested in how to recur over the current directory in a portable way. windows.h is a little ugly but if I can't do it in a portable way. So be it.

thanks :)

解决方案

char* file="C:\\Documents and Settings\\Supernovah\\Desktop\\Supernovah.bin";
FILE* pFile = fopen( file, "rb" );

这篇关于打开文件中使用C另一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆