Maincc613 error expected primary-expression before ‘int’ intp=intmallocsizeof int;
There are a couple of issues with this line of code.
Firstly, malloc returns a void pointer, so you need to cast it to the appropriate pointer type.
Secondly, the syntax for sizeof requires parentheses around the type or variable that you want to get the size of.
Here's the corrected code:
int* p = (int*)malloc(sizeof(int));
原文地址: http://www.cveoy.top/t/topic/hlAy 著作权归作者所有。请勿转载和采集!