I'm reading how pointers work here because I'm trying to understand qsort(). But the guide gives this code:
// increaser
#include <iostream>
using namespace std;
void increase (void* data, int psize)
{
if ( psize == sizeof(char) )
{ char* pchar; pchar=(char*)data; ++(*pchar); }
else if (psize == sizeof(int) )
{ int* pint; pint=(int*)data; ++(*pint); }
}
int main ()
{
char a = 'x';
int b = 1602;
increase (&a,sizeof(a));
increase (&b,sizeof(b));
cout << a << ", " << b << endl;
return 0;
}
without explaining what the line
pint=(int*)data;
and
pchar=(char*)data;
means. I understand what the rest means, but it doesbt quite make sense to me what (char*)data could mean. Is it pointing to the value of char? But how could that be if char is a variable type?