Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Arrays and pointers

Name: Anonymous 2014-02-08 8:09

void printArr(int* &arr, int size)
{
    for(int i=0;i<size;i++) cout<<arr[i]<<" ";
}

int main(int argc, char *argv[])
{
    int arr[20]={5,5,8,9,3,2,6,7,93,2,43,193,78,7,6,59,3,17,53,9};
    int* arr_p = arr;

    printArr(arr_p, 20); //this line works
    printArr(arr,20); //this line doesn't work

    pause("quit");
    return 0;

Why doesn't printArr(arr,20) work? I thought arr was just a pointer to the first value in the array.

Name: Anonymous 2014-02-25 4:25

>>1
void printArr(int* &

Stopped reading there.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List