메모리와 포인터6 : 다차원 배열에 대한 포인터
int *pnData;
-- -------
2 1
1 : 포인터 변수
2 : 대상의 자료형식
다차원 배열 : 배열의 배열
----
같은 형식의 자료가 여러개 모인 것
char[4][12]
-- ---
2 1
12개짜리가 4행 있다
중요)
char aList[3][12] = { "aaa", "bbb", ........ }
-------
1
> 1: aList[3]
> 2: char [12] -> 요소형식
char (*pList)[12] = aList;
ex)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char astrList[2][12] = { "Hello", "World" };
char(*pstrList)[12] = astrList;
puts(pstrList[0]);
puts(pstrList[1]);
return 0;
}
-------------------------------------------------------
World
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void PrintUser(char(*pUser)[12])
{
for (int i = 0; i < 3; ++i)
puts(pUser[i]);
}
int main(void)
{
char astrList[3][12] = { "철수", "길동", "영희" };
PrintUser(astrList);
return 0;
}
-----------------------------------------------
철수
길동
영희