Click here to Skip to main content
15,886,836 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to get the client's abort message with WSAAsyncSelect ? Pin
wangningyu14-Jul-11 15:25
wangningyu14-Jul-11 15:25 
Question[Solved] Passing an element from a list [modified] Pin
crgmustang13-Jul-11 13:50
crgmustang13-Jul-11 13:50 
AnswerRe: Passing an element from a list Pin
«_Superman_»13-Jul-11 14:48
professional«_Superman_»13-Jul-11 14:48 
GeneralRe: Passing an element from a list Pin
crgmustang14-Jul-11 5:28
crgmustang14-Jul-11 5:28 
QuestionPointer Maths Pin
KeithF12-Jul-11 3:25
KeithF12-Jul-11 3:25 
AnswerRe: Pointer Maths [modified] Pin
Stefan_Lang12-Jul-11 3:52
Stefan_Lang12-Jul-11 3:52 
GeneralRe: Pointer Maths Pin
Legor12-Jul-11 4:02
Legor12-Jul-11 4:02 
GeneralRe: Pointer Maths Pin
Stefan_Lang12-Jul-11 4:16
Stefan_Lang12-Jul-11 4:16 
You can't. Not inside MoveBack() anyway. Which is yet another good argument not to meddle with pointers recklessly.

The only way to ensure a pointer is inside the scope of an array is to compare it to the start address, and only the function that defined the array knows it.

So if you really wanted a 'safe' MoveBack function, you'd have to add a parameter, like this:
MyStruct* MoveBack_s(const MyStruct* p, const MyStruct* parray)
{
   MyStruct* result = 0;
   if (p > parray)
      result = p-1;
   return result;
}

Of course, even this function is not safe if you pass it a pointer to the start of a different array...

The only way to be truly safe is not to use pointers, but iterators, such as those used for the STL class vector. They contain references to the container they refer to and therefore can check their boundaries themselves.
AnswerRe: Pointer Maths Pin
Legor12-Jul-11 3:55
Legor12-Jul-11 3:55 
GeneralRe: Pointer Maths Pin
Rick York13-Jul-11 18:39
mveRick York13-Jul-11 18:39 
GeneralRe: Pointer Maths Pin
Legor17-Jul-11 0:39
Legor17-Jul-11 0:39 
GeneralRe: Pointer Maths Pin
enhzflep13-Jul-11 19:14
enhzflep13-Jul-11 19:14 
GeneralRe: Pointer Maths Pin
Richard MacCutchan13-Jul-11 21:53
mveRichard MacCutchan13-Jul-11 21:53 
QuestionHow to do 2 or more process simultaneously? Pin
Le@rner12-Jul-11 2:21
Le@rner12-Jul-11 2:21 
QuestionRe: How to do 2 or more process simultaneously? Pin
CPallini12-Jul-11 3:02
mveCPallini12-Jul-11 3:02 
AnswerRe: How to do 2 or more process simultaneously? Pin
Le@rner12-Jul-11 18:26
Le@rner12-Jul-11 18:26 
GeneralRe: How to do 2 or more process simultaneously? [fixed] Pin
CPallini12-Jul-11 21:09
mveCPallini12-Jul-11 21:09 
GeneralRe: How to do 2 or more process simultaneously? Pin
Le@rner12-Jul-11 21:16
Le@rner12-Jul-11 21:16 
GeneralRe: How to do 2 or more process simultaneously? Pin
CPallini12-Jul-11 21:24
mveCPallini12-Jul-11 21:24 
AnswerRe: How to do 2 or more process simultaneously? Pin
Albert Holguin12-Jul-11 4:56
professionalAlbert Holguin12-Jul-11 4:56 
AnswerRe: How to do 2 or more process simultaneously? Pin
jschell12-Jul-11 10:21
jschell12-Jul-11 10:21 
GeneralRe: How to do 2 or more process simultaneously? Pin
Le@rner12-Jul-11 19:54
Le@rner12-Jul-11 19:54 
GeneralRe: How to do 2 or more process simultaneously? Pin
Chris Walters13-Jul-11 6:24
Chris Walters13-Jul-11 6:24 
AnswerRe: How to do 2 or more process simultaneously? Pin
Eugen Podsypalnikov12-Jul-11 22:18
Eugen Podsypalnikov12-Jul-11 22:18 
GeneralRe: How to do 2 or more process simultaneously? Pin
Le@rner15-Jul-11 21:57
Le@rner15-Jul-11 21:57 

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.