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