- 论坛徽章:
- 84
|
没听明白你想做什么,如果没用fprintf() 怎么会把数字2 写成 字符'2'。
- [root@test9 bit]# cat test.c
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- int main()
- {
- int fd;
- char a[4] = { 2, 2, 9, 10};
- fd = open("file", O_CREAT|O_RDWR);
- write(fd, a, 4);
- }
- [root@test9 bit]# tcc -run test.c
- [root@test9 bit]# od -t x1 file
- 0000000 02 02 09 0a
- 0000004
- [root@test9 bit]#
复制代码
--------------------------------------------------------
还有一点不明白:2 2 9 存的是ascii码,可是10却存成40。 到底是 2 2 9 10 还是 '2' '2' '9' '@'
或者是你想把 '2' '2' '9' '@' 转换成 0x02 0x02 0x09 0x0a? 那样就是每个字节减去0x30...
[ 本帖最后由 yjh777 于 2007-3-23 18:47 编辑 ] |
|