http://www.winapi.co.kr/clec/cpp1/11-3-1.htm
에 좋은 설명이 있네요...
미니 님이 쓰신 글 :
: #include<stdio.h>
:
: int list(int data[][4])<===요기를 [][]으로 하면 error 가 뜹니다. 또 [3][] 이래두 error납니다..왜 그런가요?
: {
: int i,j;
:
: for(i=0; i<3; i++)
: {
: for(j=0; j<4; j++)
: {
: printf("%d", data[i][j]);
: }
: printf("\n");
: }
:
: return 0;
: }
:
: int print(int data[], int size)
: {
: int count;
:
: for(count=0; count< size; count++)
: {
: printf("%d", data[count]);
: }
: printf("\n");
:
: return 0;
: }
:
: int triple(int data[], int size)
: {
: int index;
:
: for(index=0; index<size; index++)
: data[index] *= 3;
:
: return 0;
: }
:
:
: void main()
: {
: int loop;
: int array[3][4]={ {1,2,3,4}, {4,5,6,7}, {7,8,9,10} };
:
: printf("***** source data *****\n");
: list(array);
: triple(array[0], 12);
: printf(" **** triple data *****\n");
: for( loop=0; loop<3; loop++)
: print(array[loop], 4);
: }
:
: 위에 int list(int data[][4])함수에 배열선언에 관해 질문이 있습니다.
: 그리고 값을 출력하는 int print함수에 대해서 질문인데요.
: for문을 통해 0~3까지 반복한 후 즉 data[0],data[1]...data[3]한후 for문을 탈출한 후
: 메인 함수에 for(loop=0;...)루프로 반복되더라도 값은 여전히 6, 12, 15, 16이 반복되는 것이 아닌가요?
: 왜냐하면 메인함수에서 array[0]=>array[1]로 변한후 print함수로 돌아간다해도 여전히 count값은 0~3으로
: 반복한 후 이를 data[0],data[1]...data[3]이런식으로 출력하기 때문입니다. 제가 잘못알고있나요?