Computing.Net > Forums > Programming > Passing an array pointer in C++

Passing an array pointer in C++

Reply to Message Icon

Original Message
Name: maii
Date: April 14, 2007 at 03:39:32 Pacific
Subject: Passing an array pointer in C++
OS: winxp
CPU/Ram: p4/256 mb
Comment:

Hi guys;
I would like to pass an array pointer as an argument in C++ but i'm not sure,, is this correct:
int PageFaultCount(int refPatt[], int n_frames){
int page_fault_num;
//count page fault
return page_fault_num;
}

int GenReferencePatternAndCountPageFault(int num_of_frames, int num_of_pages, int length_of_ref_patt){

int* refPattern;
refPattern = (int*)malloc(length_of_ref_patt*sizeof(int));
//create random reference string
return PageFaultCount(refPattern, num_of_frames);
}

in this example i want to pass refPattern,, any help? Thank you


Report Offensive Message For Removal

Response Number 1
Name: sickinthebox
Date: April 14, 2007 at 23:50:19 Pacific
Subject: Passing an array pointer in C++
Reply: (edit)

The header for the function should look like...
int PageFaultCount(int& refPatt, int n_frames)

~Ben;


Report Offensive Follow Up For Removal

Response Number 2
Name: Gargamel
Date: April 15, 2007 at 11:20:13 Pacific
Subject: Passing an array pointer in C++
Reply: (edit)

Hi maii.

I don't aee any problem with the code you gave. What is it exactly you are trying to do, you need help for?



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Passing an array pointer in C++

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software