210911 - TIL

210911 - TIL

# 한 것

## Clang 문법 복습

size_t, struct, typedef

# 배운 것

## size_t

According to the 1999 ISO C standard (C99), size_t is an unsigned integer type of at least 16 bit.

size_t is an unsigned data type defined by several C/C++ standards, e.g. the C99 ISO/IEC 9899 standard, that is defined in stddef.h. It can be further imported by inclusion of stdlib.h as this file internally sub includes stddef.h.

size_t is an unsigned integral data type which is defined in various header files such as:

, , , , ,

It is guaranteed to be big enough to contain the size of the biggest object the host system can handle. Basically the maximum permissible size is dependent on the compiler; if the compiler is 32 bit then it is simply a typedef(i.e., alias) for unsigned int but if the compiler is 64 bit then it would be a typedef for unsigned long long. The size_t data type is never negative.

Therefore many C library functions like malloc, memcpy and strlen declare their arguments and return type as size_t.

https://stackoverflow.com/questions/2550774/what-is-size-t-in-c

https://www.geeksforgeeks.org/size_t-data-type-c-language/

## struct

A structure is a user defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type.

‘struct’ keyword is used to create a structure.

struct address { char name[50]; char street[100]; char city[50]; char state[20]; int pin; };

#include struct Point { int x, y; }; int main() { struct Point p1 = {1, 2}; struct Point *p2 = &p1; printf("%d %d

", p1.x, p2.x); printf("%d %d

", p2->x, p2->y); return 0; } Output: 1 2 1 2

https://www.geeksforgeeks.org/structures-c/

## typedef

The C programming language provides a keyword called typedef, which you can use to give a type a new name.

typedef struct 구조체이름 { 자료형 멤버이름; } 구조체별칭;

https://www.tutorialspoint.com/cprogramming/c_typedef.htm

https://dojang.io/mod/page/view.php?id=409

from http://refigo.tistory.com/46 by ccl(A) rewrite - 2021-09-13 14:00:58