我想定义这样的路径:
#define PATH /abc/xyz/lmn
该 PATH 是一个包含文件 foo1、foo2、foo3、... foo115 的目录。
如何在“open”调用中使用这个 #define 来打开 foo1, foo2, ... foo115 ?
我基本上想使用指令来做到这一点:
fd = open("/abc/xyz/lmn/foo1", O_RDONLY);
#define PATH "/abc/xyz/lmn"
int main (int argc, char **argv)
{
char file2open[256];
int i;
for (i = 1; i <= 115; i++)
{
sprintf (file2open, "%sfoo%d", PATH, i);
fd = open (file2open, O_RDONLY)
......
close (fd);
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)