|
Sorry for the mistake...the dimensions of the array MArray[4][3][2] declared as MAarray[4*3*2]...and trying to access element Marray(3,3,2)....
The rest of the formula is correct and your correction as well...
Thanks,
|
|
|
|
|
Try this:
int d1 = 3;
int d2 = 4;
int d3 = 5;
BYTE x = 0;
BYTE *b = new BYTE[d1*d2*d3];
for (int i = 0; i < d1; i++) {
for (int j = 0; j < d2; j++) {
for (int k = 0; k < d3; k++) {
b[i*(d2*d3) + j*d3 + k] = x;
x++;
}
}
}
I hope it does what you need.
|
|
|
|
|
Thanks for your help....I have tried that and it did work...therefore, making a generalization for this, I just found this:
Let be a multidimensional array MArray[max1stdim][max2nddim]...[maxnthdim], the indexes referencing certain location be i1,i2,...,in.
If MArray is declared as
int MArray[max1stdim*max2nddim*...*maxnthdim];
then the index referencing the location (i1,i2,...in-1,in) will be:
index=(i1*max2nddim*max3rddim*...*maxnthdim)+(i2*max3rddim*...*maxnthdim)+...+(in-1)*maxnthdim+in
Then for an array MArray[4][3][2] declared as MArray[3*3*3], the single index to reference (i,j,k)will be:
index=(i*4*3)+(j*2)+k
I have tried this and it works!
Thanks again.....
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
Would be nice if you will write article about it and compare performance between different types of allocations and accesseing that memory.
|
|
|
|
|
How will I do that? What allocation and accesing methods?. Where will I submit the article?...Would you like to help me?
Thanks,
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
I understood you think addressing multi-dimensional array with one index you are computing by yourself is a faster method than addressing multi-dimensional array with pointers. So what I think is a demonstration program using two arrays of the same size but different access methods and allocation and comparison between speeds. And obviously, you will submit article with that demo program here at CP.
|
|
|
|
|
Can anyone let me know why I see 'Linking...' and after this 'Compiling...' ?
Thank you.
[Sample]
--------------------Configuration: Shared - Win32 Release--------------------
Compiling...
EnumString.cpp
Linking...
Creating library .\Release/Shared.lib and object .\Release/Shared.exp
LINK : warning LNK4089: all references to "IMAGEHLP.dll" discarded by /OPT:REF
Compiling...
Report.cpp
Report2.cpp
ReportPreviewWnd.cpp
Shared.cpp
Generating Code...
Shared.dll - 0 error(s), 3 warning(s)
|
|
|
|
|
Your monitor might be upside down...
"Hey man, Taliban, Tali me Banana."
|
|
|
|
|
i guess slow refresh rate
t!
|
|
|
|
|
big sorry, i did not realize current forum
hm, it me already happened too (no your action after build run?), do not worry
t!
|
|
|
|
|
Isn't it that feature of Pentium when it computes some instructions before it needs them?
|
|
|
|
|
I'm writing a automation EXE server in VC++ 6.0 and I want to send COM/ActiveX events to the calling program... is it possible and how ?
The project was created as a MFC application with Automation support and works fine as a Automation server for my client application.
Now I just need to notify the client of events in my automation EXE application.
Please help.... thanks
|
|
|
|
|
*BUMP*
I really need help here, guys
|
|
|
|
|
|
Hi!
I use Spy++ to watch the messages a windows sends. For example if the user clicks on a menu item Spy++ loggs the following messages:
WM_MENUSELECT
WM_COMMAND wNotifyCode: 0 (sent from a menu) wID:7224
If I doubleclick on the WM_COMMAND log a new windows opens show the parameters (wParam and lParams) sent by WM_COMMAND. Often these values have a wParam like 00001C38.
Now I want to emulate this message. I tried:
SendMessage(wnd,WM_COMMAND,00001C38,0);
But this doesn't compile. So how do I need to write the wParam/lParam parameter shown in Spy++ in order to use it in my own SendMessage function?
thanks in advance
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Thanks a lot!
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Is there a difference between
#pragma once and
#ifndef _THISDEF_
#define _THISDEF_
...
#endif ?
I've always defaulted to using the #pragma once but have noticed that others tend not to use it and favour the #ifndef instead, why is this? Am I missing something very simple?
Dylan Kenneally
London, UK
|
|
|
|
|
Good point. The #ifndef statement is only included in VC++ for backwards compatibility on older compilers and (according to MSDN) the #if !defined statement is supposed to be used instead (though it gives no reason as to why? surely the #ifndef code would be more portable because of this?). The #pragma statments are platform independent compiler directives, but I'm not sure of the difference between that and #ifndef or #if !defined, if there is any at all. I would like to know for sure though .
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
There is a difference between #ifndef and #if !defined . You can have some operations in the latter case.
For instance:
#define A
#define B
#if !defined A AND !defined B
#include "header.h"
#else
#include "secondheader.h"
#endif
Best regards,
Alexandru Savescu
|
|
|
|
|
The #ifndef block is portable, #pragma is non-portable by definition.
|
|
|
|
|
The #ifndef version has a nice advantage in that you can test whether a header has been included by checking #ifdef _THISDEF_. You can't do that with the #pragma version. And, as has been mentioned, the #ifndef way works on every compiler (for those who have to worry about portability).
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hello
I have two CDialog based classes, both with toolbars, using the technique used in the MSDN MFC sample dlgcbr32 which describes how to use toolbars and status bars in dialogs by overriding these particular control classes
I created the first class a few years ago and it works. I cannot get the toolbar button states to update in the 2nd class which I recently created, although the class is similar to the first.
I cannot get OnUpdateButtonX(CCmdUI* pCmdUI) to be called - CDlgToolBar::OnIdleUpdateCmdUI isn't being called.
Can anybody tell me what methods or messages need to be present for OnIdleUpdateCmdUI to get called.
Thanks,
John
|
|
|
|
|
Handle the WM_KICKIDLE message (#include "afxpriv.h" to get the definition) and call
UpdateDialogControls(this, FALSE);
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks, I've tried it but no luck.
The OnKickIdle method isn't called.
I'll keep trying but in case anybody has spare time here's a checklist of what's going on:
-Toolbar has same resource ID as menu. The buttons have same IDs as menu items. Menu items are updated Okay but toolbar isn't
-Class has CDlgTool member, which is derived from CToolbar and has OnIdleUpdateCmdUI method, which isn't called
-Dlg shown non-modally
m_calcDlg=new CCalcDlg(this);
m_calcDlg->Setup(m_report,m_UBuckling);
m_calcDlg->Create();
m_calcDlg->ShowWindow(SW_SHOWNORMAL);
After this I swear I'll never write a CDialog based app. ever again!
bye,
John
|
|
|
|