崩溃,求助,面试题
已知 strcpy函数的原型是 char *strcpy (char *strDest,const char *strSrc);其中strDest是目的字符串 strSrc是源字符串,不能调用C++/C的字符串库函数
写出strcpy函数???
char *strcpy (char *strDest,const char *strSrc);
{
}
我快崩溃了,面试了两次,这道题都出现了,我都不知道该怎么做。
2011-06-09 20:13
2011-06-09 20:23
程序代码:#include <stdio.h>
char * strcpy(char * str1,const char * str2) {
while(*str2)
*str1++ = *str2++;
str1 = '\0';
return str1;
}
int main(void) {
char str1[81] = "How do ", str2[81];
gets(str2);
strcpy(str1, str2);
printf("%s\n", str1);
return 0;
} /* Output:
you think?
you think?
Process returned 0 (0x0) execution time : 3.578 s
Press any key to continue.
*/这种题都不会,我劝你还是不要去面试了。
2011-06-09 20:53
还有一道题
2011-06-09 21:15
2011-06-09 22:49
2011-06-09 22:50
2011-06-09 22:59
2011-06-10 11:30