c++嵌入c代码问题
希望大家能给给点提示,先谢谢了!
//#ifdef _cplusplus
extern "C"
{
//#endif
void *malloc(int);
char*strcpy(char*,const char*);
int printf(const char*,...);
int exit(int);
int strlen(const char*);
//#ifdef _cplusplus
}
//#endif
int main()
{
/*c language program*/
const char *str="hello";
char *s=(char*)malloc(strlen(str)+1);
strcpy(s,str);
printf("%s,world\n",s);
exit(0);
return 0;
}
现在这样是可以正确运行的,但,如果保留注释的语句就出现连接错误,
我的源程序的后缀名是.cpp,我个人的观点:保留注释语句更好,也应该没有错误.
给点意见了,哈哈哈!