这部法典的正确形式是什么?
<守则>char *x = malloc(100); 守则>
守则
<守则>#include <stdlib.h> #include <stdio.h> int main(){ char *x=malloc(100); free(x); //in c++ // char *x=new char[100]; return 0; } 守则>
这里的错误
<守则>1>------ Build started: Project: memory_leaks, Configuration: Debug Win32 ------ 1>Build started 8/1/2010 2:32:21 PM. 1>PrepareForBuild: 1> Creating directory "c:usersdaviddocumentsvisual studio 2010Projectsmemory_leaksDebug". 1>InitializeBuildStatus: 1> Creating "Debugmemory_leaks.unsuccessfulbuild" because "AlwaysCreate" was specified. 1>ClCompile: 1> memory_leaks.cpp 1>c:usersdaviddocumentsvisual studio 2010projectsmemory_leaksmemory_leaksmemory_leaks.cpp(5): error C2440: initializing : cannot convert from void * to char * 1> Conversion from void* to pointer to non- void requires an explicit cast 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:00.64 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 守则>