편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2019.04.10

    c 언어 구조체 액세스 위반..


    단순히 구조체를 만들어서 값을 입력받는 코드입니다..

    왜 엑세스 위반이 발생하는지 모르겠습니다

    #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;
    
    
    
    }
    
  • 프로필 정영훈님의 편집
    날짜2019.04.10

    c 언어 구조체 액세스 위반..


    단순히 구조체를 만들어서 값을 입력받는 코드입니다..

    왜 엑세스 위반이 발생하는지 모르겠습니다

    #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;
    }
    
  • 프로필 알 수 없는 사용자님의 편집
    날짜2019.04.08

    c 언어 구조체 액세스 위반..


    단순히 구조체를 만들어서 값을 입력받는 코드입니다..

    왜 엑세스 위반이 발생하는지 모르겠습니다

    include

    include

    include

    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;
    

    }