int isBigEndian(){ short i = 1; char *p = (char *)&i; return (*p == 1) ? __little : __big;}
xint use_func(int argc, char **argv){ return 0;}int construct_para_func(int a){ int argc = 2; char *argv[3] = {NULL}; int argv_0_buf[8] = {0}; argv[0] = argv_0_buf; sprintf(argv_0_buf, "%d", a); return use_func(argc, argv);}xxxxxxxxxxint file_size2(char* filename) { struct stat statbuf; stat(filename,&statbuf); int size=statbuf.st_size; return size; } xxxxxxxxxx//包含ftruncate()头文件//包含结构体FILE头文件int main(void){ FILE *in; in = fopen("in.txt", "ab+"); int a=fileno(in); ftruncate(a,size); return 0;}xxxxxxxxxxint main(void){ int i; struct timeval tv; for (i = 0; i < 4; i++) { gettimeofday(&tv, NULL); printf("%d\t%d\n", tv.tv_usec, tv.tv_sec); sleep(1); } return 0;}pipex
int main(){ FILE *pPipe = NULL; char oneLine[256] = {0}; if ((pPipe = (FILE *)popen("ping www.baidu.com -c 3", "r")) == (FILE *)NULL) { printf("pipe create failed, pipe = %p\n", pPipe); return 1; } while (fgets(oneLine, sizeof(oneLine), pPipe)) { if (strstr(oneLine, "100% packet loss")) { printf("network bad ...\n"); break; } else { printf("pipe get string :%s\n", oneLine); } } pclose(pPipe);}~运行效果如下:[wishcell@localhost c]$ ./a.outpipe get string :PING www.baidu.com (115.239.211.112) 56(84) bytes of data.pipe get string :64 bytes from 115.239.211.112 (115.239.211.112): icmp_seq=1 ttl=53 time=35.3 mspipe get string :64 bytes from 115.239.211.112 (115.239.211.112): icmp_seq=2 ttl=53 time=66.5 mspipe get string :64 bytes from 115.239.211.112 (115.239.211.112): icmp_seq=3 ttl=53 time=45.4 mspipe get string :pipe get string :--- www.baidu.com ping statistics ---pipe get string :3 packets transmitted, 3 received, 0% packet loss, time 2003mspipe get string :rtt min/avg/max/mdev = 35.364/49.116/66.508/12.972 msxxxxxxxxxx