Click here to Skip to main content
15,921,660 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CString Pin
raju_shiva24-Aug-10 21:49
raju_shiva24-Aug-10 21:49 
GeneralRe: CString Pin
CPallini24-Aug-10 21:58
mveCPallini24-Aug-10 21:58 
GeneralRe: CString Pin
raju_shiva25-Aug-10 22:20
raju_shiva25-Aug-10 22:20 
GeneralRe: CString Pin
Shivanand Gupta25-Aug-10 8:55
Shivanand Gupta25-Aug-10 8:55 
QuestionUsing DeleteVolumeMountPoint function. Pin
dipuks24-Aug-10 11:53
dipuks24-Aug-10 11:53 
AnswerRe: Using DeleteVolumeMountPoint function. Pin
Peter_in_278024-Aug-10 13:22
professionalPeter_in_278024-Aug-10 13:22 
AnswerRe: Using DeleteVolumeMountPoint function. Pin
Sauro Viti24-Aug-10 21:11
professionalSauro Viti24-Aug-10 21:11 
GeneralRe: Using DeleteVolumeMountPoint function. Pin
dipuks25-Aug-10 2:45
dipuks25-Aug-10 2:45 
QuestionTrouble with VirtualAlloc Pin
garyflet24-Aug-10 8:30
garyflet24-Aug-10 8:30 
AnswerRe: Trouble with VirtualAlloc Pin
Luc Pattyn24-Aug-10 9:24
sitebuilderLuc Pattyn24-Aug-10 9:24 
GeneralRe: Trouble with VirtualAlloc Pin
garyflet24-Aug-10 10:08
garyflet24-Aug-10 10:08 
AnswerRe: Trouble with VirtualAlloc Pin
Luc Pattyn24-Aug-10 10:15
sitebuilderLuc Pattyn24-Aug-10 10:15 
AnswerRe: Trouble with VirtualAlloc Pin
norish24-Aug-10 19:24
norish24-Aug-10 19:24 
AnswerRe: Trouble with VirtualAlloc Pin
Aescleal25-Aug-10 0:55
Aescleal25-Aug-10 0:55 
QuestionMessage Removed Pin
24-Aug-10 6:19
garyflet24-Aug-10 6:19 
AnswerMessage Removed Pin
24-Aug-10 6:53
garyflet24-Aug-10 6:53 
GeneralRe: [Solved] Enabling SE_LOCK_MEMORY_NAME privilege Pin
Maximilien25-Aug-10 3:47
Maximilien25-Aug-10 3:47 
QuestionReusing an Incremented Variable within a Single Statement Pin
Skippums24-Aug-10 5:24
Skippums24-Aug-10 5:24 
AnswerRe: Reusing an Incremented Variable within a Single Statement Pin
Sauro Viti24-Aug-10 5:41
professionalSauro Viti24-Aug-10 5:41 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Skippums24-Aug-10 6:26
Skippums24-Aug-10 6:26 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
norish24-Aug-10 19:30
norish24-Aug-10 19:30 
AnswerRe: Reusing an Incremented Variable within a Single Statement Pin
Luc Pattyn24-Aug-10 5:50
sitebuilderLuc Pattyn24-Aug-10 5:50 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Skippums24-Aug-10 6:15
Skippums24-Aug-10 6:15 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Luc Pattyn24-Aug-10 6:33
sitebuilderLuc Pattyn24-Aug-10 6:33 
GeneralRe: Reusing an Incremented Variable within a Single Statement Pin
Skippums24-Aug-10 6:54
Skippums24-Aug-10 6:54 
I have two arrays being sent to my function from an outside source. The first array is a list of 1-based indices into the the second array that contains the data. When the first array has an index of 0, this means that there is no associated data element in the second array. So, for example:
const size_t indexArray[] = {1, 0, 3, 2, 0};
DATA_TYPE *const dataArray = new DATA_TYPE[3] - 1; // This is a 1-indexed array and has three elements in it (since max(indexArray) == 3)
Now, as I said, no matter what I do I have to read in the values of dataArray using API calls on a per-element basis. I could very easily copy the values from indexArray into another variable in my C-code, subtracting 1 from each element as I perform the copy. However, I think it is more straightforward (and more efficient) to just get a pointer to the existing indexArray data (using an API call) and subtract one from my dynamically allocated dataArray object as I illustrated in the above code. Using this approach, I can compare each element from indexArray to 0 to test for the special condition, whereas if I did a copy and subtracted one I would have to test against numeric_limits<size_t>::max(), and pray that the max() macro from windows.h wasn't included by some other header file that I am including. I may also need to make the copy loop more complex, if I don't want to assume that the result of (0u - 1u) is the maximum unsigned integer.

Hopefully that explains in better detail why I am not just converting it to 0-based indices.
Sounds like somebody's got a case of the Mondays

-Jeff

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.