Very new to C here, and I think I barely understand the concept of pointers, but the syntax is a bit confusing, so it's hard for me to understand what this expression means x = (char *) &a;.
The rest of the function is for reference:
#include<stdio.h>
int main()
{
int a;
char *x;
x = (char *) &a;
a = 512;
x[0] = 1;
x[1] = 2;
printf("%d\n",a);
return 0;
}
In particular, why write x = (char *) &a;instead x = &a;? What adds added (char *)to change the expression?
source
share