Arrays of Structure
Arrays of Structure
STRUCTURES
int main() {
struct myStructure s1;
return 0;
}
prog.c:12:15: error: assignment to expression with
array type
HOWEVER, THERE IS A SOLUTION FOR THIS! YOU
CAN USE THE STRCPY() FUNCTION AND ASSIGN THE
VALUE TO S1.MYSTRING, LIKE THIS:
struct myStructure {
int myNum;
char myLetter;
char myString[30]; // String
};
int main() {
struct myStructure s1;
return 0;
}
OUTPUT
My string: Some text
COPY STRUCTURES
s2 = s1;
ARRAY OF STRUCTURES VS. ARRAY WITHIN A
STRUCTURE IN C/C++