null
vuild_
Nodes
Flows
Hubs
Login
MENU
Notifications
Login
⌂
c-lang-advanced
Structure
advanced-pointers
•
Function Pointer
•
Pointer to Pointer
•
Void Pointer
data-structures
•
Linked List
•
Stack & Queue
•
Tree & Graph
algorithms
•
Sorting Algorithms
•
Complexity Analysis
bit-ops
•
Bitwise Operators
•
Bit Fields
•
Bit Tricks
system-prog
•
Process
•
Signal
•
IPC (Inter-Process Communication)
concurrency
•
Threads Basics
•
Mutex & Semaphore
•
Race Condition
optimization
•
Compiler Flags
•
Cache Locality
•
Profiling
design-patterns
•
OOP in C
•
Callback Pattern
•
State Machine
project
•
Mini Shell
•
TCP Echo Server
Flow Structure
Pointer to Pointer
3 / 25
Linked List
☆ Star
↗ Full
Void Pointer
#c
#c-lang
#advanced
#pointer
#void-pointer
@devpc
|
2026-03-29 13:49:32
|
GET /api/v1/flows/6/nodes/67?fv=1&nv=1
Context:
Flow v1
→
Node v1
0
Views
0
Calls
# Void Pointer > void* 범용 포인터, 제네릭 함수 구현 패턴 ## 학습 목표 - `void *`의 특성과 용도를 이해한다 - `void *`를 활용한 제네릭 함수를 구현한다 - 타입 캐스팅 시 주의사항을 파악한다 ## 내용 ### void* 기본 ```c int x = 42; void *vp = &x; // 역참조 전에 반드시 캐스팅 필요 int val = *(int *)vp; ``` ### 제네릭 함수 구현 패턴 ```c void print_value(void *data, char type) { switch (type) { case 'i': printf("%d\n", *(int *)data); break; case 'f': printf("%f\n", *(float *)data); break; case 'c': printf("%c\n", *(char *)data); break; } } ``` ### qsort와 void* ```c int cmp(const void *a, const void *b) { return (*(int *)a - *(int *)b); } int arr[] = {5, 2, 8, 1}; qsort(arr, 4, sizeof(int), cmp); ``` ## 참고 - `void *`는 타입 안전성이 없으므로 캐스팅 실수에 주의해야 한다
Pointer to Pointer
Linked List
// COMMENTS
ON THIS PAGE
No content selected.