【发布时间】:2015-03-13 15:24:30
【问题描述】:
我要做一个项目,但我遇到了问题。 我从读取中收到一个字符串,但是当我看到缓冲区中有哪些数据时,它会在文件末尾显示一个“\n”。但是我不需要它来使用 after 来处理我的函数中的参数。
我的代码:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
int main()
{
char buf[100];
read(1, buf, sizeof(buf));
printf("%s", &buf);
// If I write: "/tmp/", printf shows: "/tmp/\n"
DIR* drp = opendir(buf);
// Logically: no such file or directory
}
谢谢
【问题讨论】:
标签: printf buffer stat opendir