#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> // Added for read() function
#define rwmode 0
int main()
{
int fd;
char buffer[1024];
int n;
fd = open("/data/workspace/myshixun/case1/testFIle", rwmode);
if (fd < 0)
{
printf("Open file error!\n");
exit(1);
}
else
printf("open testFIle ok!\n");
// Use read function to read data into the buffer
n = read(fd, buffer, sizeof(buffer) - 1);
if (n < 0)
{
printf("Read file error!\n");
exit(1);
}
buffer[n] = '\0';
printf("%s\n", buffer);
close(fd);
return 0;
}
读文件系统函数
最新推荐文章于 2023-08-31 23:32:45 发布