- 论坛徽章:
- 0
|
版主已经说得很明白了 如果你还是有疑惑 可以用 对比 strace 调试下
比如
#include <stdio.h>
#include <assert.h>
#include <string.h>
char * fname = "hello.txt";
char * poem = " Poem is a song by nu metal band \
Taproot and the lead single from \
their second major label album, Welcome. \
It was released in 2002 and met with the \
highest success of any Taproot single, \
reaching #5 on the Billboard Mainstream Rock Tracks. ...\
" ;
int main() {
FILE * file_ptr = fopen( fname,"w+") ;
assert(file_ptr) ;
fwrite(poem, 1,strlen(poem), file_ptr);
fclose(file_ptr);
return 0 ;
}
strace -c a.out
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
nan 0.000000 0 1 read
nan 0.000000 0 1 write
nan 0.000000 0 3 open
nan 0.000000 0 3 close
nan 0.000000 0 1 execve
nan 0.000000 0 3 3 access
nan 0.000000 0 3 brk
nan 0.000000 0 2 munmap
nan 0.000000 0 1 mprotect
nan 0.000000 0 7 mmap2
nan 0.000000 0 3 fstat64
nan 0.000000 0 1 set_thread_area
------ ----------- ----------- --------- --------- ----------------
100.00 0.000000 29 3 total |
|