Click here to Skip to main content
15,894,362 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Size Of Control Objects Pin
Bacon Ultimate Cheeseburger1-Aug-09 17:57
Bacon Ultimate Cheeseburger1-Aug-09 17:57 
GeneralRe: Size Of Control Objects Pin
ForNow1-Aug-09 19:39
ForNow1-Aug-09 19:39 
GeneralRe: Size Of Control Objects (Part 1) Pin
Bacon Ultimate Cheeseburger1-Aug-09 23:57
Bacon Ultimate Cheeseburger1-Aug-09 23:57 
GeneralRe: Size Of Control Objects (part 2) Pin
Bacon Ultimate Cheeseburger1-Aug-09 23:58
Bacon Ultimate Cheeseburger1-Aug-09 23:58 
GeneralRe: Size Of Control Objects (part 2) Pin
ForNow2-Aug-09 1:31
ForNow2-Aug-09 1:31 
GeneralRe: Size Of Control Objects (part 2) Pin
Bacon Ultimate Cheeseburger2-Aug-09 3:02
Bacon Ultimate Cheeseburger2-Aug-09 3:02 
GeneralRe: Size Of Control Objects (part 2) Pin
ForNow2-Aug-09 5:02
ForNow2-Aug-09 5:02 
GeneralRe: Size Of Control Objects (part 2) Pin
Bacon Ultimate Cheeseburger2-Aug-09 14:57
Bacon Ultimate Cheeseburger2-Aug-09 14:57 
GeneralRe: Size Of Control Objects (part 2) Pin
ForNow2-Aug-09 5:15
ForNow2-Aug-09 5:15 
GeneralRe: Size Of Control Objects (part 2) Pin
Bacon Ultimate Cheeseburger2-Aug-09 15:04
Bacon Ultimate Cheeseburger2-Aug-09 15:04 
GeneralRe: Size Of Control Objects (part 2) Pin
ForNow2-Aug-09 15:17
ForNow2-Aug-09 15:17 
GeneralRe: Size Of Control Objects (part 2) Pin
Bacon Ultimate Cheeseburger2-Aug-09 15:38
Bacon Ultimate Cheeseburger2-Aug-09 15:38 
GeneralRe: Size Of Control Objects Pin
ForNow1-Aug-09 20:49
ForNow1-Aug-09 20:49 
GeneralRe: Size Of Control Objects Pin
Bacon Ultimate Cheeseburger1-Aug-09 21:36
Bacon Ultimate Cheeseburger1-Aug-09 21:36 
GeneralRe: Size Of Control Objects Pin
ForNow1-Aug-09 21:49
ForNow1-Aug-09 21:49 
Questionvoid pointer? Pin
sam_psycho30-Jul-09 6:21
sam_psycho30-Jul-09 6:21 
AnswerRe: void pointer? Pin
molesworth30-Jul-09 7:49
molesworth30-Jul-09 7:49 
GeneralRe: void pointer? Pin
sam_psycho30-Jul-09 8:06
sam_psycho30-Jul-09 8:06 
GeneralRe: void pointer? [modified] Pin
Joe Woodbury30-Jul-09 8:20
professionalJoe Woodbury30-Jul-09 8:20 
GeneralRe: void pointer? Pin
sam_psycho30-Jul-09 8:30
sam_psycho30-Jul-09 8:30 
GeneralRe: void pointer? Pin
Joe Woodbury30-Jul-09 8:35
professionalJoe Woodbury30-Jul-09 8:35 
GeneralRe: void pointer? Pin
sam_psycho30-Jul-09 9:01
sam_psycho30-Jul-09 9:01 
GeneralRe: void pointer? Pin
Joe Woodbury30-Jul-09 9:45
professionalJoe Woodbury30-Jul-09 9:45 
I don't understand why you are using a void*. It has no concept of size of what it's pointing to. You are removing type safety for no reason.

That said, when you increment do arithmetic on a pointer, that arithmetic is done according to the size of the object pointed to by that pointer. In this case you are casting ptr to an (int*). Therefore, you only need to increment ptr by 1 to take you to the next position. (As an aside, (int*)ptr += 1; will not compile on many compilers--you would have to have ptr = (int*)ptr + 1;

Two other points:

You don't need to cast arr to a void*, that cast is automatic.

You have an off by one error; you have four items in your array, but you only go through the loop three times.

You simply shouldn't be using a void* in a case like this. It's an extremely bad idea. It would be better to use arr[] directly or if you must use a pointer, use an int*.
GeneralRe: void pointer? Pin
sam_psycho30-Jul-09 16:43
sam_psycho30-Jul-09 16:43 
GeneralRe: void pointer? Pin
Joe Woodbury30-Jul-09 17:04
professionalJoe Woodbury30-Jul-09 17:04 

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.