You are trying to allocate memory for foo
and assign it the address of the allocated memory. That won't work. foo
is an array, and has already memory allocated to it (81 char
elements.) And because it's an array, you can't assign an address to it.
What you want is to copy the a
string to foo
:
scanf("%s", a);
strcpy(get->foo, a);
However, you can do better by actually limiting the scan and copy operations to 81 characters, so that you won't write past the end of foo
nor a
:
fgets(a, 81, stdin);
strncpy(get->foo, a, 81);
Consulting the docs for fgets() and strncpy() is a good idea (there you can find out why you can specify 81 instead of 80 in the call to fgets().) You should always be careful not to write past the end of an array.