struct1 [C] 구조체(struct)와 공용체(union) 구조체(struct)의 멤버 변수로 배열을 사용할 때 주의사항 에러 상황 : 구조체의 멤버 변수인 배열의 시작 주소에 문자열을 입력할 수 없음 #include typedef struct student { char no[10]; char name[20]; }STUDENT; int main(void) { STUDENT stu; stu.no = "2018316"; //에러 stu.name = "park";//에러 printf("학번: %s, 이름: %s \n", stu.no, stu.name); return 0; } [해결방법 1] strcpy함수 사용 : 문자열을 대입할 때 사용 #include #include typedef struct student { char no[10]; char name[20]; }.. 2021. 2. 25. 이전 1 다음