U E D R , A S I H C RSS

이승한/질문

~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* 기를 리다.
기만 는 방법 ??

다른 문.
?? 배 ;;
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;
}



Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:31
Processing time 0.0108 sec