typedef struct Node {
char number[5];
struct Node *next;
} Node;
char userString[5];
scanf("%s", userString);
Node *newNode = malloc(sizeof(Node));
newNode->number = userString;
I'm trying to read a string entered by the user into "number" in the struct Node, but I'm getting an error that says "assignment to expression with array type". What I can do to fix this?
strcpy()to copy a string. Use%4sin the format string to prevent buffer overflow.strncpy()man pagestrncpy()the padding of the unused space in the array can get costly.