I don't quite get this, here is a simple program I picked from the internet written in C.
EXAMPLE 1.
int main(void) {
char * b;
memmove((char *)&b, "saaaa", 6);
puts((char *)&b);
return 0;
}
and here is my own code, EXAMPLE 2.
int main(void) {
char b[10];
memmove(b, "baaaa", 6);
printf("%s\n", b);
return 0;
}
Why is it using &
in EXAMPLE 1 ? I have mostly used &
sign when I want to assign a value to the variable like in scanf(). But in EXAMPLE 1, I am not assigning it. The only thing I do is I move the string saaaa
to the variable b.
And why using (char *)
method is required any way?