본문 바로가기

Native/C

구조체 기본형

[code]#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct _sMy
{
    int cbsize;
    char *data;
}sMy;

int main(int argc, char *argv[])
{
    sMy *pStr;

    pStr = (sMy *) malloc(sizeof(sMy));
    pStr->cbsize = sizeof(sMy)+80; //
    pStr->data = (char *) malloc(80);
    memset(pStr->data,0,80);

    free(pStr->data);
    free(pStr);
    return 0;
}[/code]

'Native > C' 카테고리의 다른 글

기억영역 클래스(auto,extern,register,static)  (0) 2013.10.02
간단한 c 프로그램과 cron으로 mysql 백업을 편하게...  (0) 2013.10.02
정의 상수  (0) 2013.10.02
point  (0) 2013.10.02
malloc  (0) 2013.10.02