Click here to Skip to main content
15,850,298 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to get the client's abort message with WSAAsyncSelect ? Pin
wangningyu14-Jul-11 16:25
wangningyu14-Jul-11 16:25 
Question[Solved] Passing an element from a list [modified] Pin
crgmustang13-Jul-11 14:50
crgmustang13-Jul-11 14:50 
AnswerRe: Passing an element from a list Pin
«_Superman_»13-Jul-11 15:48
professional«_Superman_»13-Jul-11 15:48 
GeneralRe: Passing an element from a list Pin
crgmustang14-Jul-11 6:28
crgmustang14-Jul-11 6:28 
QuestionPointer Maths Pin
KeithF12-Jul-11 4:25
KeithF12-Jul-11 4:25 
AnswerRe: Pointer Maths [modified] Pin
Stefan_Lang12-Jul-11 4:52
Stefan_Lang12-Jul-11 4:52 
GeneralRe: Pointer Maths Pin
Legor12-Jul-11 5:02
Legor12-Jul-11 5:02 
GeneralRe: Pointer Maths Pin
Stefan_Lang12-Jul-11 5:16
Stefan_Lang12-Jul-11 5: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 4:55
Legor12-Jul-11 4:55 
GeneralRe: Pointer Maths Pin
Rick York13-Jul-11 19:39
mveRick York13-Jul-11 19:39 
GeneralRe: Pointer Maths Pin
Legor17-Jul-11 1:39
Legor17-Jul-11 1:39 
GeneralRe: Pointer Maths Pin
enhzflep13-Jul-11 20:14
enhzflep13-Jul-11 20:14 
GeneralRe: Pointer Maths Pin
Richard MacCutchan13-Jul-11 22:53
mveRichard MacCutchan13-Jul-11 22:53 
QuestionHow to do 2 or more process simultaneously? Pin
Le@rner12-Jul-11 3:21
Le@rner12-Jul-11 3:21 
QuestionRe: How to do 2 or more process simultaneously? Pin
CPallini12-Jul-11 4:02
mveCPallini12-Jul-11 4:02 
AnswerRe: How to do 2 or more process simultaneously? Pin
Le@rner12-Jul-11 19:26
Le@rner12-Jul-11 19:26 
GeneralRe: How to do 2 or more process simultaneously? [fixed] Pin
CPallini12-Jul-11 22:09
mveCPallini12-Jul-11 22:09 
GeneralRe: How to do 2 or more process simultaneously? Pin
Le@rner12-Jul-11 22:16
Le@rner12-Jul-11 22:16 
GeneralRe: How to do 2 or more process simultaneously? Pin
CPallini12-Jul-11 22:24
mveCPallini12-Jul-11 22:24 
AnswerRe: How to do 2 or more process simultaneously? Pin
Albert Holguin12-Jul-11 5:56
professionalAlbert Holguin12-Jul-11 5:56 
AnswerRe: How to do 2 or more process simultaneously? Pin
jschell12-Jul-11 11:21
jschell12-Jul-11 11:21 
GeneralRe: How to do 2 or more process simultaneously? Pin
Le@rner12-Jul-11 20:54
Le@rner12-Jul-11 20:54 
GeneralRe: How to do 2 or more process simultaneously? Pin
Chris Walters13-Jul-11 7:24
Chris Walters13-Jul-11 7:24 
AnswerRe: How to do 2 or more process simultaneously? Pin
Eugen Podsypalnikov12-Jul-11 23:18
Eugen Podsypalnikov12-Jul-11 23:18 
GeneralRe: How to do 2 or more process simultaneously? Pin
Le@rner15-Jul-11 22:57
Le@rner15-Jul-11 22: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.