초기화되지 않은 포인터에서 사용자 입력을 읽을 수 없습니다. 대신 struct 데이터 유형의 변수를 갖고 → operator
에 의해 내부 요소에 액세스하기 전에 해당 주소를 포인터에 할당하십시오.예시
#include <stdio.h>
struct example{
char name[20];
};
main(){
struct example *ptr;
struct example e;
puts("enter name");
gets(e.name);
ptr=&e;
puts(ptr->name);
} 출력
위 코드의 일반적인 결과
enter name Disha You entered Disha