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.0104 sec