- ·上一篇知名企业资料:一道INTEL笔试题
- ·下一篇知名企业资料:intel的笔试题:关于排序
当前位置:毕业生招聘信息网 → 知名企业资料 → IT/电信 → Intel(英特尔) → 知名企业资料内容
intel面试题
作者:佚名 来源:不详 发布时间:2004-4-26 21:47:00
#include <stdio.h>
char *reverse(char* str)
{
int len=0, i=0;
char *pstr=str, *ptemp,*pd;
while(*++pstr)
len++;
pstr--;
//ptemp=(char*)malloc(len+1);
ptemp=(char*)malloc(len+1);
pd=ptemp;
while(len--){
*ptemp=*pstr;
ptemp++;
pstr--;
i++;
}
*ptemp=*pstr;
ptemp++;
*ptemp=''\0'';
return pd;
}
main()
{
char string[40]="Hello World!";
char *pstr=string;
printf("%s", pstr);
printf("%s", reverse(pstr));
}
运行结果为 :
Segmentation Fault (core dumped)
但把char string[40]="Hello World!";
改为char string[40]="Hello World";
结果正确!!!
|
请在邮件中注明:信息来自Byszp.COM
[各地求职生活指南]
[进入查询知名企业资料]
![]() ![]() |


