문 ¶
~cpp
void Test(int * Ascores)
{
cout << "in function : ";
cout << sizeof(Ascores) << " " << sizeof(Ascores[0]) << endl;
}
void main()
{
int scores[4]={1,2,3,4};
cout<<"in main : ";
cout << sizeof(scores) << " " << sizeof(scores[0]) << endl;
Test(scores);
}
strlen 럼 int 배 길를 구는 를 던 되는 부.
메 들 sizeof(scores)는 배 기를 리는 반면 들 sizeof(scores)는 int* 기를 리다.
메 럼 배기만 리 는 방법 나??
메 들 sizeof(scores)는 배 기를 리는 반면 들 sizeof(scores)는 int* 기를 리다.
메 럼 배기만 리 는 방법 나??
다른 문.
를 배 길는 는가?? 배 가 ;;
vs 는 방 동로 를 는 바법를 firend 를 는 나??
를 배 길는 는가?? 배 가 ;;
vs 는 방 동로 를 는 바법를 firend 를 는 나??
강경 나대로 답변 ¶
가 는 답 겠만 본다. 달는 것 기 때문 는 것 배 가 . 게다가 를 게 되 그 값 변경면 본 값 변게 되고. 그래 나는 멤 변를 만들 달 값 복 든. 보 달를 때 러 그 본 값 고 복값 는 ? 그 로그래머가 는 것. 밑 말대로 구고 단게 .
~cpp
#include<iostream>
using namespace std;
void Test(int *aArray, int aLength)
{
int *copyArray = new int[aLength];//달 배과 같 기 로 배
for(int index = 0; index < aLength; index++)
copyArray[index] = aArray[index];//값 복
cout << "in function : ";
cout << sizeof(copyArray[0])*aLength << " " << sizeof(copyArray[0]) << endl;
//기부는 를 로 만든 드!
cout << "\n변경 copyArray : ";//변경 값 달 배과 같다
for(index = 0; index < aLength; index++)
cout << copyArray[index] << " ";
cout << endl;
for(index = 0; index < aLength; index++)//copyArray 모든 값 0로 기
copyArray[index] = 0;
cout << "변경 copyArray : ";
for(index = 0; index < aLength; index++)
cout << copyArray[index] << " ";
cout << endl;
delete []copyArray;//메모리 는 !!!
}
void main()
{
int arrayLength;
int scores[4]={1,2,3,4};
cout<<"in main : ";
cout << sizeof(scores) << " " << sizeof(scores[0]) << endl;
arrayLength = sizeof(scores)/sizeof(scores[0]);
Test(scores, arrayLength);
//검!!
cout << "\n 달된 값 변 scores 값 변 는다.\nscores: ";
for(int index = 0; index < arrayLength; index++)
cout << scores[index] << " ";
cout << endl;
}










