NVIDIA Interview Question
Country: United States
yeahh I think the declaration needs to be char* buf = (char*) malloc(10 * sizeof(char));
It would be good to specify what exactly the syntax error is. The thing that's definitely an error is the comma between 10 and sizeof. Many compilers will also complain about the implicit cast of char* to int.
OR
long error(){
char* buf = (char*)malloc(10*sizeof(char));
return reinterpret_cast<long>(buf);
}
syntax error malloc takes only one argument.
- Anonymous January 25, 2012