字符串倒置问题
下面代码在vc++环境下编译老是编不通,显示D:\project\Cpp1.cpp(8) : error C2065: 'malloc' : undeclared identifier
D:\project\Cpp1.cpp(10) : error C2440: 'initializing' : cannot convert from 'char' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
D:\project\Cpp1.cpp(12) : error C2106: '=' : left operand must be l-value
执行 cl.exe 时出错.
Cpp1.obj - 1 error(s), 0 warning(s)
请指教
#include<string.h>
#include<stdio.h>
main()
{
char *src="hello,world";
char *dest=NULL;
int len=strlen(src);
dest=(char*)malloc(len);
char *d=dest;
char *s=src[len];
while(len--!=0)
d++=s--;
printf("%s",dest);
return 0;
}