You can do it like this:
#include <stdio.h> struct Name {char d[11];}; int main (){ char str[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; scanf("%s",str); // The below is C99 style. struct Name new = { .d = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; struct Name new2 = { .d = "hi mum"}; // Memcpy does the job as well memcpy(new.d, str, sizeof(str)); }
EDIT:
If what you want is to copy whatever you got in your str-buffer to Name, you could do it like above. You could also do it like this.
struct Name new; scanf("%s", new.d); /* Work directly on the structure. */
For more info on C99-style struct initialization, check this StackOverflow-question: C struct initialization with char array
Also heed R. Sahu's warning to not read more than the array can hold.
new. While it is legal to do this in C,newis a reserved keyword in C++ and it might cause confusion.newas it will confound people who don't realize C++ is a different language to C (and so they might start to realize this as a result)newis an appropriate name for a new instance of something.