Click here to Skip to main content
15,922,145 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Pointer to structure problem... Pin
RChin3-Jun-03 23:32
RChin3-Jun-03 23:32 
GeneralRe: Pointer to structure problem... Pin
BhaskarBora4-Jun-03 1:29
BhaskarBora4-Jun-03 1:29 
GeneralRe: Pointer to structure problem... Pin
Dominik Reichl3-Jun-03 23:32
Dominik Reichl3-Jun-03 23:32 
GeneralRe: Pointer to structure problem... Pin
IrishSonic4-Jun-03 0:07
IrishSonic4-Jun-03 0:07 
GeneralRe: Pointer to structure problem... Pin
Dominik Reichl4-Jun-03 0:48
Dominik Reichl4-Jun-03 0:48 
GeneralRe: Pointer to structure problem... Pin
Rage4-Jun-03 0:55
professionalRage4-Jun-03 0:55 
GeneralThanks guys, have it sorted now. Pin
IrishSonic4-Jun-03 2:48
IrishSonic4-Jun-03 2:48 
GeneralRe: Pointer to structure problem... Pin
John M. Drescher4-Jun-03 4:37
John M. Drescher4-Jun-03 4:37 
What you really need is a vector or list of structures but this is a little too complicated to start off with. You can look up vector or list in the help for examples if you want. I assume that you will not know how many structures you will have at compile time and that is why you want a dynamic array. You can create a large array of pointers to your structure. This will take 4 bytes per element. Then allocate your structures when you need them. Have an integer keep track of the current number of structures. Try this:

struct s_Test
{
char name[30];
}
struct s_Test* Test[10];
int nTestCount = 0;

void main()
{
// Add a struct and initialize
Test[nTestCount] = new Test;
strcpy( Test[nTestCount]->name,"Paul");
nTestCount++;

// Add a struct and initialize
Test[nTestCount] = new Test;
strcpy( Test[nTestCount]->name,"John");
nTestCount++;

for(int i=0; i < nTestCount;i++) {
printf("%s\n",Test[i]->name);
}

return;
}
QuestionDoes the static variable modifier make variable access faster? Pin
Dominik Reichl3-Jun-03 22:48
Dominik Reichl3-Jun-03 22:48 
AnswerRe: Does the static variable modifier make variable access faster? Pin
FlyingDancer3-Jun-03 23:19
FlyingDancer3-Jun-03 23:19 
GeneralRe: Does the static variable modifier make variable access faster? Pin
Dominik Reichl3-Jun-03 23:28
Dominik Reichl3-Jun-03 23:28 
AnswerRe: Does the static variable modifier make variable access faster? Pin
Andrew Walker4-Jun-03 1:03
Andrew Walker4-Jun-03 1:03 
GeneralRe: Does the static variable modifier make variable access faster? Pin
BhaskarBora4-Jun-03 1:48
BhaskarBora4-Jun-03 1:48 
GeneralRe: Does the static variable modifier make variable access faster? Pin
Andrew Walker4-Jun-03 1:53
Andrew Walker4-Jun-03 1:53 
GeneralRe: Does the static variable modifier make variable access faster? Pin
BhaskarBora4-Jun-03 21:12
BhaskarBora4-Jun-03 21:12 
AnswerRe: Does the static variable modifier make variable access faster? Pin
BhaskarBora4-Jun-03 1:42
BhaskarBora4-Jun-03 1:42 
GeneralRe: Does the static variable modifier make variable access faster? Pin
Dominik Reichl4-Jun-03 4:42
Dominik Reichl4-Jun-03 4:42 
Questionhow to make Floppy-Disk-Device's LED blinking Pin
FlyingDancer3-Jun-03 22:25
FlyingDancer3-Jun-03 22:25 
AnswerRe: how to make Floppy-Disk-Device's LED blinking Pin
Toni784-Jun-03 19:51
Toni784-Jun-03 19:51 
GeneralRe: how to make Floppy-Disk-Device's LED blinking Pin
FlyingDancer4-Jun-03 20:13
FlyingDancer4-Jun-03 20:13 
GeneralRe: how to make Floppy-Disk-Device's LED blinking Pin
Toni784-Jun-03 20:51
Toni784-Jun-03 20:51 
GeneralRe: how to make Floppy-Disk-Device's LED blinking Pin
FlyingDancer4-Sep-03 15:12
FlyingDancer4-Sep-03 15:12 
GeneralCFtpFileFind Bug ! Pin
oz_the_wizard3-Jun-03 21:52
oz_the_wizard3-Jun-03 21:52 
GeneralMaking selected item bk 50% transparent in a ownerdrawn clistctrl Pin
justin2233-Jun-03 21:42
justin2233-Jun-03 21:42 
GeneralRe: Making selected item bk 50% transparent in a ownerdrawn clistctrl Pin
Cris4-Jun-03 4:38
Cris4-Jun-03 4:38 

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.