C언어 사용법

OpenJR·2023년 5월 29일
0

구조체 사용법

#include <stdio.h>
#include <string.h>

typedef struct POINT {
    float x;
    float y;
    float z;
} POINT_t;

int main() {
  # C++ 20  부터 가능
  POINT_t p = {.x = 10.0f, .y = 5.0f, .z = 0.0f};
  
  // Memory setting
  memset(&p, 0, sizeof(POINT_t));
  
  return 0;
}

메모리 Align

첫번째 변수 크기의 배수로 메모리를 구성함
float, float, char[10], short = 20 바이트
float, short, float, char[10] = 24 바이트
alignas, alignof

profile
Jacob

0개의 댓글