嵌入式Linux题库(6)

2018-12-29 22:46

}

A、for(i=3;i< MAXFILE;i--)B、for(i=0;i< MAXFILE;i--) C、for(i=3;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!=0B、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]


嵌入式Linux题库(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:街道2018年党建工作调研报告

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: