This has nothing to do with structs – arrays in C are not assignable:
char a[20];
a = "foo"; // error
you need to use strcpy:
strcpy( a, "foo" );
or in your code:
strcpy( sara.first, "Sara" );
More Related Contents:
- "." or "->" C struct accessor [duplicate]
- Removing digits and all punctuation except apostrophe from a string in C
- Why is this segfaulting? Can someone explain the valgrind error?
- free() not working correctly with struct
- Reading and analyzing rooms from text file
- char c[]=”Albus”; printf(“%c”, c); [closed]
- Structure padding and packing
- Is char signed or unsigned by default?
- How to do scanf for single char in C [duplicate]
- Why should we typedef a struct so often in C?
- When are anonymous structs and unions useful in C11?
- Get a substring of a char* [duplicate]
- Passing a 2D array of structs
- Determine if char is a num or letter
- C struct initialization using labels. It works, but how?
- Why does strchr take an int for the char to be found?
- Initialize/reset struct to zero/null
- Why can’t C compilers rearrange struct members to eliminate alignment padding? [duplicate]
- Casting one struct pointer to another – C
- Char to int conversion in C
- Are there any downsides to passing structs by value in C, rather than passing a pointer?
- Rationale behind the container_of macro in linux/list.h
- In C, why can’t an integer value be assigned to an int* the same way a string value can be assigned to a char*?
- sizeof single struct member in C
- Why does C have a distinction between -> and .?
- Array of structs replacing values over itself
- Counting number of occurrences of a char in a string in C
- assigning more than one character in char
- Get list of C structure members
- Why does my function not modify the value of variable in a struct in C?