write与lseek的综合运用

By admin in 澳门新葡亰官网app on 2019年5月6日

那些实例依照命令行参数实行相应的读学操作:

linux系统一编写程:read,write与lseek的汇总选用,linuxlseek

其1实例依照命令行参数进行相应的读学操作:

用法:

usage:./io file {r<length>|R<length>|w<string>|s<offset>}...

file参数:文件名, 固然不设有会自动创设

r<length>:  如r5,   r:
读取操作,表示在时下文件指针后边读取七个字节的从头到尾的经过,以文件情势输出.

Rubicon<length>:如Sportage伍 
 科雷傲:读取操作,表示在当下文件指针前边读取6个字节的开始和结果,以十6进制方式输出.

w<string>: 如wghostwu: 
w代表写入操作,表示在近日文件指针前边写入四个字节的剧情

s<offset>: 如s一千, 从文件伊始把指针移动1000个字节

源代码:

澳门新葡亰官网app 1
1 /*================================================================ 2
* Copyright (C) 2018 . All rights reserved. 3 * 4 * 文件名称:io.c 5
* 创 建 者:ghostwu(吴华) 6 * 创立日期:二零一八年05月1二十一日 7 * 描
述:write,open,lseek结合示例 八 * 9
================================================================*/ 10
11 #include <stdio.h> 12 #include <stdlib.h> 13 #include
<string.h> 14 #include <sys/types.h> 15 #include
<sys/stat.h> 16 #include <fcntl.h> 17 #include
<limits.h> 18 #include <sys/types.h> 19 #include
<unistd.h> 20 二一 //参数字符串转整数 2二 int str_to_long( char*
str ); 23 24 int main(int argc, char *argv[]) 贰伍 { 2六 int i = 2; 贰柒int fd = -一; 2八 //保存字符串转整形的结果 2玖 int res; 30 //写入的字节数
31 ssize_t num; 3二 //动态分配的堆内部存款和储蓄器 33 char* buf; 3四 //读取的字节数
35 int numread; 36 三七 if( argc < 叁 || strcmp( argv[1], “–help” )
== 0 ) { 38 printf( “usage:%s file
{r<length>|R<length>|w<string>|s<offset>}…\n”,
argv[0] ); 39 exit( -1 ); 40 } 41 42 fd = open( argv[1], O_RDWR |
O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH ); 四三 if(
fd < 0 ) { 4四 printf( “文件%s张开大概创设战败”, argv[1] ); 45 exit(
-1 ); 46 } 47 48 for( i = 2; i < argc; i++ ){ 49 switch(
argv[i][0] ){ 50 //移动指针, s前边跟移动的字节数 5一 case ‘s’: 5二 res
= str_to_long( &argv[i][1] ); 伍三 if( -1 == res ) { 5肆 printf(
“字符串->整形调换退步\n” ); 55 exit( -1 ); 56 } 57 lseek( fd, res,
SEEK_CUCRUISER ); 5八 printf( “%s—>指针移动成功\n”, argv[i]澳门新葡亰官网app, ); 5玖break; 60 //写入文件, w前边跟写入的故事情节 陆一 case ‘w’: 6贰 num = write( fd,
&argv[i][1], strlen( &argv[i][1] ) ); 陆三 if( num == -1 ) { 6四printf( “%s写入退步\n”, argv[i] ); 陆伍 } 66 printf(
“%s成功写入%ld个字节\n”, argv[i], num ); 6七 break; 6八 case ‘r’:
//字符输出 6玖 case ‘君越’: //十陆进制输出 70 res = str_to_long(
&argv[i][1] ); 71 if( -一 == res ) { 7二 printf(
“字符串->整形调换退步\n” ); 7三 exit( -1 ); 7四 } 7伍 buf = malloc( res
); 76 if( buf == NULL ){ 77 printf( “内存分配退步” ); 7八 exit( -一 ); 79} 80 numread = read( fd, buf, res ); 八一 if( -壹 == numread ) { ⑧二 printf(
“数据读取战败\n” ); 八三 exit( -壹 ); 八四 } 85 if( 0 == numread ) { 8陆printf( “已经到达文件尾巴部分” ); 8七 }else { 88 printf( “%s: “, argv[i] );
89 for ( int j = 0 ; j < numread; j ++ ){ 90 if( ‘r’ ==
argv[i][0] ) { 91 printf( “%c”, buf[j] ); 92 }else { 93 printf(
“%02x “, buf[j] ); 94 } 95 } 96 } 97 break; 98 default: 99 printf(
“参数%s必须以[rRws]中的2个发端\n”, argv[i] ); 100 } 101 } 102 103
return 0; 104 } 105 106 int str_to_long( char* str ) { 107 char*
endstr; 108 int res; 109 res = strtol( str, &endstr, 10 ); 110 if( (res
== LONG_MIN) || (res == LONG_MAX) ) { 111 return -1; 112 } 113 return
res; 114 } View Code

总体的示范效果:

 1 [email protected]:~/c_program/tlpi/chapter4$ ls
 2 cp  cp.c  cp.c.copy  io  io.c  strtol  strtol.c
 3 [email protected]:~/c_program/tlpi/chapter4$ !g
 4 gcc io.c -o io
 5 [email protected]:~/c_program/tlpi/chapter4$ ls -l
 6 total 56
 7 -rwxrwxr-x 1 ghostwu ghostwu  9016 1月  10 17:16 cp
 8 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:15 cp.c
 9 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:16 cp.c.copy
10 -rwxrwxr-x 1 ghostwu ghostwu 13360 1月  10 22:19 io
11 -rw-rw-r-- 1 ghostwu ghostwu  2743 1月  10 22:19 io.c
12 -rwxrwxr-x 1 ghostwu ghostwu  8824 1月  10 20:47 strtol
13 -rw-rw-r-- 1 ghostwu ghostwu   616 1月  10 20:47 strtol.c
14 [email protected]:~/c_program/tlpi/chapter4$ ./io test.txt
15 usage:./io file {r<length>|R<length>|w<string>|s<offset>}...
16 [email protected]:~/c_program/tlpi/chapter4$ ls -l
17 total 56
18 -rwxrwxr-x 1 ghostwu ghostwu  9016 1月  10 17:16 cp
19 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:15 cp.c
20 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:16 cp.c.copy
21 -rwxrwxr-x 1 ghostwu ghostwu 13360 1月  10 22:19 io
22 -rw-rw-r-- 1 ghostwu ghostwu  2743 1月  10 22:19 io.c
23 -rwxrwxr-x 1 ghostwu ghostwu  8824 1月  10 20:47 strtol
24 -rw-rw-r-- 1 ghostwu ghostwu   616 1月  10 20:47 strtol.c
25 [email protected]:~/c_program/tlpi/chapter4$ ./io test.txt s1000 wghostwu
26 s1000--->指针移动成功
27 wghostwu成功写入7个字节
28 [email protected]:~/c_program/tlpi/chapter4$ ls -l
29 total 60
30 -rwxrwxr-x 1 ghostwu ghostwu  9016 1月  10 17:16 cp
31 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:15 cp.c
32 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:16 cp.c.copy
33 -rwxrwxr-x 1 ghostwu ghostwu 13360 1月  10 22:19 io
34 -rw-rw-r-- 1 ghostwu ghostwu  2743 1月  10 22:19 io.c
35 -rwxrwxr-x 1 ghostwu ghostwu  8824 1月  10 20:47 strtol
36 -rw-rw-r-- 1 ghostwu ghostwu   616 1月  10 20:47 strtol.c
37 -rw-rw-r-- 1 ghostwu ghostwu  1007 1月  10 22:20 test.txt
38 [email protected]:~/c_program/tlpi/chapter4$ ./io test.txt r1007
39 r1007: [email protected]:~/c_program/tlpi/chapter4$ ./io test.txt R1007
40 R1007: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 67 68 6f 73 74 77 75 
41 [email protected]:~/c_program/tlpi/chapter4$ ./io test.txt s1000 r7
42 s1000--->指针移动成功
43 r7: [email protected]:~/c_program/tlpi/chapter4$ ./io test.txt s1000 R7
44 s1000--->指针移动成功

 

那么些实例依据命令行参数进行对应的读学操作: 用法: usage:./io file
{rlength|XC60length|w stri…

用法:

usage:./io file {r<length>|R<length>|w<string>|s<offset>}...

file参数:文件名, 若是不存在会自动成立

r<length>:  如r伍,   r:
读取操作,表示在此时此刻文件指针前边读取两个字节的从头到尾的经过,以文件情势输出.

昂Cora<length>:如揽胜5 
 ENCORE:读取操作,表示在当下文件指针前边读取多少个字节的剧情,以十陆进制方式输出.

w<string>: 如wghostwu: 
w表示写入操作,表示在眼下文件指针前边写入四个字节的剧情

s<offset>: 如s1000, 从文件初步把指针移动1000个字节

源代码:

澳门新葡亰官网app 2澳门新葡亰官网app 3

  1 /*================================================================
  2 *   Copyright (C) 2018 . All rights reserved.
  3 *   
  4 *   文件名称:io.c
  5 *   创 建 者:ghostwu(吴华)
  6 *   创建日期:2018年01月10日
  7 *   描    述:write,open,lseek结合示例
  8 *
  9 ================================================================*/
 10 
 11 #include <stdio.h>
 12 #include <stdlib.h>
 13 #include <string.h>
 14 #include <sys/types.h>
 15 #include <sys/stat.h>
 16 #include <fcntl.h>
 17 #include <limits.h>
 18 #include <sys/types.h>
 19 #include <unistd.h>
 20 
 21 //参数字符串转整数
 22 int str_to_long( char* str );
 23 
 24 int main(int argc, char *argv[])
 25 {
 26     int i = 2;
 27     int fd = -1;
 28     //保存字符串转整形的结果
 29     int res;
 30     //写入的字节数
 31     ssize_t num;
 32     //动态分配的堆内存
 33     char* buf;
 34     //读取的字节数
 35     int numread;
 36 
 37     if( argc < 3 || strcmp( argv[1], "--help" ) == 0 )  {
 38         printf( "usage:%s file {r<length>|R<length>|w<string>|s<offset>}...\n", argv[0] );
 39         exit( -1 );
 40     }
 41 
 42     fd = open( argv[1], O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH );
 43     if( fd < 0 ) {
 44         printf( "文件%s打开或者创建失败", argv[1] );
 45         exit( -1 );
 46     }
 47     
 48     for( i = 2; i < argc; i++ ){
 49         switch( argv[i][0] ){ 
 50             //移动指针, s后面跟移动的字节数
 51             case 's':
 52                 res = str_to_long( &argv[i][1] );
 53                 if( -1 == res ) {
 54                     printf( "字符串->整形转换失败\n" );
 55                     exit( -1 );
 56                 }
 57                 lseek( fd, res, SEEK_CUR );    
 58                 printf( "%s--->指针移动成功\n", argv[i] );
 59                 break;
 60             //写入文件, w后面跟写入的内容
 61             case 'w':
 62                 num = write( fd, &argv[i][1], strlen( &argv[i][1] ) );
 63                 if( num == -1 ) {
 64                     printf( "%s写入失败\n", argv[i] );
 65                 }
 66                 printf( "%s成功写入%ld个字节\n", argv[i], num );
 67                 break;
 68             case 'r': //字符输出
 69             case 'R': //十六进制输出
 70                 res = str_to_long( &argv[i][1] );
 71                 if( -1 == res ) {
 72                     printf( "字符串->整形转换失败\n" );
 73                     exit( -1 );
 74                 }
 75                 buf = malloc( res );
 76                 if( buf == NULL ){
 77                     printf( "内存分配失败" );
 78                     exit( -1 );
 79                 }
 80                 numread = read( fd, buf, res );
 81                 if( -1 == numread ) {
 82                     printf( "数据读取失败\n" );
 83                     exit( -1 );
 84                 }
 85                 if( 0 == numread ) {
 86                     printf( "已经到达文件尾部" );
 87                 }else {
 88                     printf( "%s: ", argv[i] );
 89                     for ( int j = 0 ; j < numread; j ++ ){
 90                         if( 'r' == argv[i][0] ) {
 91                             printf( "%c", buf[j] );
 92                         }else {
 93                             printf( "%02x ", buf[j] );
 94                         }
 95                     }
 96                 }
 97                 break;
 98             default:
 99                 printf( "参数%s必须以[rRws]中的一个开头\n", argv[i] );
100         }
101     }
102 
103     return 0;
104 }
105 
106 int str_to_long( char* str ) {
107     char* endstr;
108     int res;
109     res = strtol( str, &endstr, 10 );
110     if( (res == LONG_MIN) || (res == LONG_MAX) ) {
111         return -1;
112     }
113     return res;
114 }

View Code

完整的演示效果:

 1 ghostwu@ubuntu:~/c_program/tlpi/chapter4$ ls
 2 cp  cp.c  cp.c.copy  io  io.c  strtol  strtol.c
 3 ghostwu@ubuntu:~/c_program/tlpi/chapter4$ !g
 4 gcc io.c -o io
 5 ghostwu@ubuntu:~/c_program/tlpi/chapter4$ ls -l
 6 total 56
 7 -rwxrwxr-x 1 ghostwu ghostwu  9016 1月  10 17:16 cp
 8 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:15 cp.c
 9 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:16 cp.c.copy
10 -rwxrwxr-x 1 ghostwu ghostwu 13360 1月  10 22:19 io
11 -rw-rw-r-- 1 ghostwu ghostwu  2743 1月  10 22:19 io.c
12 -rwxrwxr-x 1 ghostwu ghostwu  8824 1月  10 20:47 strtol
13 -rw-rw-r-- 1 ghostwu ghostwu   616 1月  10 20:47 strtol.c
14 ghostwu@ubuntu:~/c_program/tlpi/chapter4$ ./io test.txt
15 usage:./io file {r<length>|R<length>|w<string>|s<offset>}...
16 ghostwu@ubuntu:~/c_program/tlpi/chapter4$ ls -l
17 total 56
18 -rwxrwxr-x 1 ghostwu ghostwu  9016 1月  10 17:16 cp
19 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:15 cp.c
20 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:16 cp.c.copy
21 -rwxrwxr-x 1 ghostwu ghostwu 13360 1月  10 22:19 io
22 -rw-rw-r-- 1 ghostwu ghostwu  2743 1月  10 22:19 io.c
23 -rwxrwxr-x 1 ghostwu ghostwu  8824 1月  10 20:47 strtol
24 -rw-rw-r-- 1 ghostwu ghostwu   616 1月  10 20:47 strtol.c
25 ghostwu@ubuntu:~/c_program/tlpi/chapter4$ ./io test.txt s1000 wghostwu
26 s1000--->指针移动成功
27 wghostwu成功写入7个字节
28 ghostwu@ubuntu:~/c_program/tlpi/chapter4$ ls -l
29 total 60
30 -rwxrwxr-x 1 ghostwu ghostwu  9016 1月  10 17:16 cp
31 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:15 cp.c
32 -rw-rw-r-- 1 ghostwu ghostwu  1752 1月  10 17:16 cp.c.copy
33 -rwxrwxr-x 1 ghostwu ghostwu 13360 1月  10 22:19 io
34 -rw-rw-r-- 1 ghostwu ghostwu  2743 1月  10 22:19 io.c
35 -rwxrwxr-x 1 ghostwu ghostwu  8824 1月  10 20:47 strtol
36 -rw-rw-r-- 1 ghostwu ghostwu   616 1月  10 20:47 strtol.c
37 -rw-rw-r-- 1 ghostwu ghostwu  1007 1月  10 22:20 test.txt
38 ghostwu@ubuntu:~/c_program/tlpi/chapter4$ ./io test.txt r1007
39 r1007: ghostwughostwu@ubuntu:~/c_program/tlpi/chapter4$ ./io test.txt R1007
40 R1007: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 67 68 6f 73 74 77 75 
41 ghostwu@ubuntu:~/c_program/tlpi/chapter4$ ./io test.txt s1000 r7
42 s1000--->指针移动成功
43 r7: ghostwughostwu@ubuntu:~/c_program/tlpi/chapter4$ ./io test.txt s1000 R7
44 s1000--->指针移动成功

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 澳门新葡亰官网app 版权所有