为什么文本格式不可读。 [英] why the text is in unreadable format.

查看:87
本文介绍了为什么文本格式不可读。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是Linux编程新手,编写了一个文件编写程序,文件已创建,但文件文件不是可读格式,任何人都可以说出原因吗?

这是程序

Hi All,
I am new to Linux programming, wrote an file writing program,the file is created but the text is file is not in readable format can anyone tell why?
Here is the program

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>

#define BUF_SIZE

int main()
{
int fd;
char* buffer = "hi";
fd = open("/home/abc/Desktop/log.txt", O_WRONLY | O_CREAT | O_APPEND,777);
 ssize_t out = write (fd,;this is me",12);
printf("value of out is %d",out);
close(fd);
}

推荐答案

可能是因为你的程序没有编译,因此也没有生成EXE文件。所以你正在运行什么来创建文件,我不知道...



尝试更改:

Probably, because your program doesn't compile, and thus doesn't produce an EXE file. So exactly what you are running to create the file, I don't know...

Try changing:
ssize_t out = write (fd,;this is me",12);



To

ssize_t out = write (fd,"this is me",12);



它可能无效 - 我还没有测试过 - 但至少它会编译并产生一个EXE文件...


It may not work - I haven't tested it - but at least it will compile and produce an EXE file...


这篇关于为什么文本格式不可读。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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