题目内容
阅读以下关于C语言及C代码的叙述。 [说明] 在开发某嵌入式系统时,设计人员根据系统要求,分别编写了如下三部分程序,其中: [C代码1]是李工为了在嵌入式平台上开发一段可变参数函数,在X86平台上实现的一个参数个数可变函数实例。 [C代码2]是王工在编写软件时,自己编写的内存拷贝函数。 [C代码3]是赵工编写的一段数据处理的程序,其中fun0的含义为从已创建的一个单向链表中查找倒数第index个结点。他的设计思路为:首先创建两个指针ptr1,ptr2,并且都指向链表头,然后ptr1向前走index步,这样ptr1和ptr2之间就间隔index个结点,然后ptr1和ptr2同时向前步进,当ptr1到达最后一个结点时,ptr2就是倒数第index个结点了。ReverseList()为赵工编写的对已有单向链表进行逆序重排的函数。 [C代码1] long sum (int i,…) int*p,j; long s=0; p=&i+1; for(j=0;j<i;j++) s+=p[j]; return s; long Sum=sum(3,1,2,3); [C代码2] static int pent; ……·· void*MyMemcpy(void*dest, const void*src, int n) char*pDest=(char*)dest; char*pSrc=(char*)src; for(int i=0; i<n; i++) *(pDest +i)=*(pSrc+i); return dest; [C代码3] node *fun(node*head, int index) node *ptr1,*ptr2; int i=0: ptr1=head; ptr2=head; if( head==NULL || head->next==NULL ) return ptr1; while (i<index) (1) ; if (ptrl==NULL) return head; i++; while (ptr1->next !=NULL) ptr1=ptr1->next; (2) ; return (3) ; node* ReverseList (node *head) node *temp1=NULL; node *temp2=NULL; node *temp3=NULL; if ((head->next==NULL) || (head==NULL)) return head; temp1=head; temp3=temp1->next; temp1->next=NULL; while (temp3->next !=NULL) temp2=temp3; temp3=temp3->next; (4) ; temp1=temp2; temp3->next=temp1; return (5) ; 请问C代码2中static的作用是什么const的作用是什么王工自己编写的内存拷贝函数安全吗如存在缺陷,请指出缺陷在哪里。
查看答案
搜索结果不匹配?点我反馈
更多问题