【发布时间】:2015-02-27 18:59:46
【问题描述】:
我编写此代码是为了从服务器发送文件夹中的文件内容列表,以便在客户端中查看。该代码有效,但我看到所有文件都没有换行符。如何查看带有换行符或空格的文件? 例如,现在我看到:“file1.txtfile2.txtfile3.txt”,我会看到“file1.txt 文件 2.txt 文件 3.txt"
谢谢!
DIR *dp;
int rv, stop_received;
struct dirent *ep;
dp = opendir ("./");
char *newline="\n";
if (dp != NULL) {
while (ep = readdir(dp))
rv = send(conn_fd, ep->d_name, strlen(ep->d_name), 0);
(void)closedir(dp);
} else
perror ("Couldn't open the directory");
close(conn_fd);
【问题讨论】: