1 #include <stdio.h>
 2 #include<unistd.h> 
 3 #include<sys/types.h> 
 4 #include<sys/stat.h> 
 5 #include<fcntl.h> 
 6 #include <memory.h>
 7 int main() 
 8 { 
 9 int fd,size,FileLen = 0,cur = 0; 
10 char s [ ]="Linux Programmer!",buffer[100]; 
11 
12 fd = open("/proc/uptime",O_RDONLY);
13 while(1){
14     FileLen=lseek(fd,0,SEEK_END);
15     lseek(fd,SEEK_SET,0);
16 
17 while(size = read(fd,buffer,sizeof(buffer))){
18     cur +=size;
19     printf("%d---%s\n",size,buffer);
20     
21     memset(buffer,0,sizeof(buffer));
22     if(cur>=FileLen){
23         cur = 0;
24         break;    
25     }
26 
27 }
28 
29 lseek(fd,SEEK_SET,0);
30 sleep(1);
31 
32 }
33 close(fd); 
34 
35 }

 

相关文章:

  • 2021-10-03
  • 2021-10-21
  • 2022-12-23
  • 2022-02-18
  • 2021-08-15
  • 2021-07-06
  • 2021-09-15
  • 2021-10-12
猜你喜欢
  • 2021-10-21
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
相关资源
相似解决方案