I have this piece of code that works in C but not C++, is that any way to make it work on both C and C++ ?
void foo(void* b)
{
int *c = b;
printf("%d\n",*c);
}
int main ()
{
int a = 1000;
foo(&a);
return 0;
}
output:
C++:
1 In function 'void foo(void*)':
2 Line 3: error: invalid conversion from 'void*' to 'int*'
3 compilation terminated due to -Wfatal-errors.
C:
1000
Please help