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