c 언어 구조체 액세스 위반..
조회수 1561회
단순히 구조체를 만들어서 값을 입력받는 코드입니다..
왜 엑세스 위반이 발생하는지 모르겠습니다
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_STACK_SIZE 100
#pragma warning(disable: 4996)
typedef struct _element {/*data 구조체*/
int key;
char name[20];
char address[100];
}element;
typedef struct _node {
struct _node *leftChild;
element data;
struct _node *rightChild;
}node;
void push(node *pushnode);
node *stack[MAX_STACK_SIZE];
int top = 0;
int main(void)
{
char string[256];
char *tok;
node* temp;
memset(&temp, 0, sizeof(temp));
printf("삽입할 자료(학번, 이름, 주소)를 입력하시오: ");
gets_s(string, 256);
tok = strtok(string, " ");
temp->data.key = atoi(tok);//예외가 throw됨 : 쓰기 액세스 위반입니다..................
tok = strtok(NULL, " ");
strcpy(temp->data.name, tok);
tok = strtok(NULL, "");
strcpy(temp->data.address, tok);
temp->leftChild = temp->rightChild = NULL;
}
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
댓글 입력