以下2個函數實質上是相同的函數嗎?int *參數與int []參數完全相同
即,int*
與int[]
完全相同?
int myFunction(int* xVals, int* yVals, int nVertices);
int myFunction(int xVals[], int yVals[], int nVertices);
如何使用第一個功能?也就是說,我如何傳遞參數中的數組?以下有效/正確?
int xVals[5], yVals[5], zVals[5];
myFunction(xVals, yVals, zVals, 5);
// or should it be..
myFunction(&xVals[0], &yVals[0], &zVals[0], 5);
你確定你不是指'int xVals []'嗎? – cnicutar
@cnicutar是的sry它應該是 –
沒問題,現在我可以推薦你[但我聽說char'a []'與char'* a']相同(http://c-faq.com/ aryptr/aryptr2.html) – cnicutar