}
A、for(i=3;i< MAXFILE;i--)选项>B、for(i=0;i< MAXFILE;i--)选项> C、for(i=3;i< MAXFILE;i++)选 D、for(i=0;i< MAXFILE;i++)选项> <题目>hello.c和hello.h位于同一目录下,源代码如下所示。 /*hello.c*/ int main() { printf(\}
/*hello.h*/
#include <stdio.h>
要求编写Makefile文件实现对这两个文件的编译,Makefile文件如下所示。请选出应填写在空白处的选项。 /*Makefile*/
hello:hello.c hello.h _____B_____
A、gcc hello.c&hello.h -o hello选项> B、gcc hello.c hello.h -o hello选项> C、make hello.c&hello.h -o hello选项> D、make hello.c hello.h -o hello选项>
<题目>下面的程序建立一个守护进程,然后在该守护进程中新建一个子进程,该子进程暂停10s,然后自动退出,并由守护进程收集子进程退出的消息。子进程退出后,守护进程循环暂停,其间隔时间为10s。子进程和守护进程的退出消息均在/var/log/messages中输出。请选出应填写在空白处的选项。 #define MAXFILE 65535 int main(void) { pid_t child1,child2; int i; child1 = fork(); if( _____A_____ ) { perror(\ exit(1); } else if( child1 > 0 ) exit( 0 ); openlog(\ setsid(); chdir( \ umask( 0 ); for( i = 0 ; i < MAXFILE ; i++ ) { close( i ); }
child2 = fork(); if( child2 == -1 ) { perror(\ exit(1); } else if( child2 == 0 ) { syslog( LOG_INFO, \ sleep(10); syslog( LOG_INFO, \ exit(0); } else { waitpid( child2, NULL, 0); syslog( LOG_INFO , \ closelog(); while(1) { sleep(10); } } }
A、child1 == -1选项> B、child1 == 0选项> C、child1 > 0选项> D、child1 >= 0选项> <题目>下面的程序实现对文件属性的查询。请选出应填写在空白处的选项。 static int get_file_size_time(const char *filename) {
struct stat statbuf;
if(stat(filename,&statbuf)==-1) { printf(\ return(-1); }
if(S_ISDIR(statbuf.st_mode)) return(1); if(S_ISREG(statbuf.st_mode)) printf(\st_mtime)); return(0); }
int main(int argc,char **argv) {
DIR *dirp;
struct dirent *direntp;
int stats;
if( ______A____ ) { printf(\ exit(1); }
if(((stats=get_file_size_time(argv1))==0)||(stats==-1))exit(1); if((dirp=opendir(argv1))==NULL) { printf(\ exit(1); }
while((direntp=readdir(dirp))!=NULL) if(get_file_size_time(direntp->d_name)==-1) break; closedir(dirp); exit(1); }
A、argc!=1选项> B、argc!=2选项> C、argv!=1选项> D、argv!=2选项> <题目>下面的程序实现文件的拷贝。请选出应填写在空白处的选项。 #define BUFFER_SIZE 1024 int main(int argc,char **argv) { int from_fd,to_fd; int bytes_read,bytes_write; char bufferBUFFER_SIZE; char *ptr; if( ____D______ ) { fprintf(stderr,\ exit(1); }
if((from_fd=open(argv1,O_RDONLY))==-1) { fprintf(stderr,\ exit(1); }
if((to_fd=open(argv2,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR))==-1) { fprintf(stderr,\ exit(1); }
while(bytes_read=read(from_fd,buffer,BUFFER_SIZE)) { if((bytes_read==-1)&&(errno!=EINTR))
break; else if(bytes_read>0) { ptr=buffer; while(bytes_write=write(to_fd,ptr,bytes_read)) { if((bytes_write==-1)&&(errno!=EINTR)) break; else if(bytes_write==bytes_read) break; else if(bytes_write>0) { ptr+=bytes_write; bytes_read-=bytes_write; } } if(bytes_write==-1) break; } }
close(from_fd); close(to_fd); exit(0); }
A、argc!=0选项>B、argc!=1选项> C、argc!=2选项> D、argc!=3选项> <题目>下面的程序实现对字符串倒序输出。请选出应填写在空白处的选项。 int display1 (char *string) { printf (\}
_____B_____ { char *string2; int size,i; size = strlen (string1); string2 = (char *) malloc (size + 1); for (i = 0; i< size; i++) string2[size+1] = ' '; printf(\}
int main () { char string[] = \ display1 (string);
display2 (string); }
A、int display2 (char *string)选项> B、int display2 (char *string1)选项> C、int display2 (char *string2)选项>
<题目>下面的程序实现对字符串倒序输出。请选出应填写在空白处的选项。 int display1 (char *string) { printf (\}
int display2 (char *string1) { char *string2; int size,i; size = strlen (string1); string2 = (char *) malloc (size + 1); for (i = 0; i< size; i++) ______A____ ; string2[size+1] = ' '; printf(\}
int main () { char string[] = \ display1 (string); display2 (string); }
A、string2[size - i -1] = string1[i]选项>B、string2[size - i ] = string1[i]选项> C、string2[size - i + 1] = string1[i]选项>D、string2[size - i ] = string1[i+1]选项>