Click here to Skip to main content
15,891,316 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem using RichTextBox Pin
Tom Wright25-Aug-04 6:21
Tom Wright25-Aug-04 6:21 
GeneralRe: Problem using RichTextBox Pin
BlackDice25-Aug-04 7:43
BlackDice25-Aug-04 7:43 
GeneralRe: Problem using RichTextBox Pin
David Crow25-Aug-04 10:21
David Crow25-Aug-04 10:21 
GeneralRe: Problem using RichTextBox Pin
SuperTank25-Aug-04 10:40
SuperTank25-Aug-04 10:40 
GeneralDeriving from a CStatic Pin
act_x25-Aug-04 6:01
act_x25-Aug-04 6:01 
GeneralRe: Deriving from a CStatic Pin
Michael P Butler25-Aug-04 6:28
Michael P Butler25-Aug-04 6:28 
GeneralRe: Deriving from a CStatic Pin
Maximilien25-Aug-04 6:33
Maximilien25-Aug-04 6:33 
GeneralGeneral Pointer to Variables Pin
sweep12325-Aug-04 5:49
sweep12325-Aug-04 5:49 
Is it possible to declare a series of variables and then assign a pointer to the start (i.e. the first variable).
I wish to use a user defined database which will hold the display format, type and an offset into the variables location in memory.

Basically I will fill an array of item details and declare the items;

e.g.

static ITEM_DETAILS items[NO_ITEMS] = {<br />
   "%0.2f",   display format<br />
   "float"  // type<br />
   "£",   // Units<br />
  "Current Cost"   // Title of the item<br />
  , "0000"   // Memory offset<br />
<br />
   "%d",   display format<br />
   "unsigned short"  // type<br />
   "N/A",   // Units<br />
  "Number of Units",   // Title of the item<br />
  "0004"   // Memory offset 4 as its a float' 2 for short etc<br />
<br />
  etc<br />
 };
Now the items will be declared as follows:-

float cost;   // Item cost<br />
unsigned short noOfItems;   // No off<br />
CString itemName;   // Name<br />
etc

Now my question is how do I go about declaring a pointer to the first variable (start of the memory that the variables are held) and is it OK to add offsets to this pointer, i.e. to obtain data item2 (noOfItems which has the offset 0004)

e.g.
LPVOID ptr = &cost; // Pointer to the start of the memory location

so to access the item noOfItems I would do the following:-
int offset = atoi(items[1].offset);  // 2nd item<br />
data = *(ptr + offset);   // i.e. *(ptr + 0004);


I need the variables in contagious memory and is a LPVOID the right choice.

I was thinking of shared memory, but I have always used a structure to access items and not a general pointer.

Any help please.
GeneralRe: General Pointer to Variables Pin
jmkhael25-Aug-04 5:56
jmkhael25-Aug-04 5:56 
GeneralRe: General Pointer to Variables Pin
sweep12326-Aug-04 2:17
sweep12326-Aug-04 2:17 
GeneralRe: General Pointer to Variables Pin
sweep12326-Aug-04 5:35
sweep12326-Aug-04 5:35 
GeneralRe: CRecordset Record Updating(Debug Assertion Failure) problem Pin
David Crow25-Aug-04 5:47
David Crow25-Aug-04 5:47 
GeneralRe: CRecordset Record Updating(Debug Assertion Failure) problem Pin
raed25-Aug-04 5:55
raed25-Aug-04 5:55 
GeneralRe: CRecordset Record Updating(Debug Assertion Failure) problem Pin
jmkhael25-Aug-04 5:59
jmkhael25-Aug-04 5:59 
GeneralRe: CRecordset Record Updating(Debug Assertion Failure) problem Pin
raed25-Aug-04 20:38
raed25-Aug-04 20:38 
Questionhow to move the event handler from main view Pin
hyling25-Aug-04 5:43
hyling25-Aug-04 5:43 
GeneralINI Files Pin
si_6925-Aug-04 5:30
si_6925-Aug-04 5:30 
GeneralRe: INI Files Pin
David Crow25-Aug-04 5:45
David Crow25-Aug-04 5:45 
GeneralRe: INI Files Pin
si_6925-Aug-04 22:40
si_6925-Aug-04 22:40 
GeneralRe: INI Files Pin
David Crow26-Aug-04 3:01
David Crow26-Aug-04 3:01 
GeneralWinSock2 Pin
Micie25-Aug-04 5:20
Micie25-Aug-04 5:20 
GeneralRe: WinSock2 Pin
Tom Wright25-Aug-04 5:33
Tom Wright25-Aug-04 5:33 
GeneralRe: WinSock2 Pin
Micie25-Aug-04 5:36
Micie25-Aug-04 5:36 
GeneralRe: WinSock2 Pin
Tom Wright25-Aug-04 5:46
Tom Wright25-Aug-04 5:46 
GeneralRe: WinSock2 Pin
palbano25-Aug-04 19:32
palbano25-Aug-04 19:32 

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.