Click here to Skip to main content
15,889,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to get the client's abort message with WSAAsyncSelect ? Pin
wangningyu13-Jul-11 15:30
wangningyu13-Jul-11 15:30 
AnswerRe: How to get the client's abort message with WSAAsyncSelect ? Pin
Member 131329513-Jul-11 18:32
Member 131329513-Jul-11 18:32 
AnswerRe: How to get the client's abort message with WSAAsyncSelect ? Pin
includeh1014-Jul-11 9:44
includeh1014-Jul-11 9:44 
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 
Folks,

Quick question in relation to the Pointer Maths in this program below, The Output is as follows:


1, 2, 3
. . .
. . .
. . .
245026, 245027, 245028
246017, 246018, 246019
247010, 247011, 247012
248005, 248006, 248007
249002, 249003, 249004
The Last Record is : 245028


Using the MoveBack function I expected the output to be 248007, the record before the current record, however it seems we move back 12 blocks of memory to 245028 and not the 12bytes I expected. Can someone explain to me whats going on here and how I can modify the code to get 248007 from the function? Thanks In Advance

#include "stdafx.h"
#include <conio.h>

typedef struct MyStruct{
	int i;
	int j;
	int k;
} TheStruct;

int MoveBack(int *iPos);

int main(int argc, char* argv[])
{
	TheStruct ts[500];
	int i = 0;

	for(i = 0; i < 500; i++)
	{
		ts[i].i = i * i + 1;
		ts[i].j = i * i + 2;
		ts[i].k = i * i + 3;
	}

	for(i = 0; i < 500; i++)
	{
		printf("%ld, %ld, %ld \r\n" ,ts[i].i ,ts[i].j, ts[i].k);

		if(i == 499)
		{
			//Pointer - Move back to last record
			printf("The Last Record is : %ld" , MoveBack(&ts[i].k));
		}
		
	}

	while(!getch());
	
	return 0;
}

int MoveBack(int *iPos)
{
	int *i = iPos - sizeof(TheStruct);
	return *i;
}

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 
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 

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.