|
You could do this -
void earth(float** ihl, int** go)
{
}
|
|
|
|
|
the two parameters of two dimensional arrays are from input. I need to pass them to the function to process. After the process I do not need them. So after the function call, I delete these two arrays.
Do you think I can pass them in a better way ?
Thanks
|
|
|
|
|
mrby123 wrote: So after the function call, I delete these two arrays.
Only if you used new (or malloc() ) to create them. Otherwise, there's nothing to delete.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
You are right. I used "new" created these variables before calling the function, I am planning to delete them after the function call.
Now I need a good way to pass these 2D arrays to the function
Thanks
|
|
|
|
|
mrby123 wrote:
Now I need a good way to pass these 2D arrays to the function
What's wrong with:
float **ihl;
int **go;
earth(ihl, go);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
My 2D arrays are read from input files. I need to pass these data to the function to process.
Thanks
|
|
|
|
|
If the array bounds are fixed then you may safely use them, for instance:
int fun(int a[3][5])
{
}
in the other hand, if the array bounds may vary then you need to pass them to the function, fo instance (this may depend on how do you allocated the array)
int fun(int * a, int m, int n)
{
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Hi,
These are compiled code to pass two dimensional arrays in a function and how to call the function.
1. function definition:
void CCib_procDlg::de_time(float **delms,float **sds,float **delmih,float **sdih
,unsigned int nlinks[])
{ ......}
2. declared in the header file .h file:
void CCib_procDlg::de_time(float**,float**,float**,float**,unsigned int[]);
3. called in the main program:
......
de_time(delms,sds,delmih,sdih,nlinks);
......
Please check my code and make comments. Thanks for the help
|
|
|
|
|
if de_time function doesn't know in advance the array bounds then your code is bad.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
How to make it know the vound of the arraies ? thanks.
I need to declare the function in the header file. I do not know how to declare it ?
|
|
|
|
|
You must pass them to the function. You may consider packing all the required data inside a struct .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks. Could you give me some code fragments ? I am new learner on this.
Thanks again
|
|
|
|
|
>>void earth(float ihl[][], int go[][])
>>{
>>}
>>
>>I found these not working. How to pass these two dimensional arrays into a function?
>
>>Thanks
Hi. I came up with a hack. Simply define a size of the array in the function header like this : void earth(float ihl[3][3], int go[3][3]) .
See Visual C++ code below.
#include <stdio.h>
#include <stdlib.h>
void add(int swap[3][2], int swap2[3][2])
{
int temp,i;
for (i=0; i<3; i++)
{
temp = swap[i][0];
swap[i][0] = swap[i][1];
swap[i][1] = temp;
}
return;
}
void display(int array[3][2],int array2[3][2] )
{
int count=0,count1=0;
for (count=0;count<3;count++)
for (count1=0;count1<2;count1++)
printf("%d ", array[count][count1]);
printf("\n");
puts("");
}
int main()
{
int i[3][2]= { {1,2}, {3,4}, {5,6} };
display(i,i);
add(i,i);
display(i,i);
return 0;
}
...
|
|
|
|
|
thanks. that will be helpful.
|
|
|
|
|
Thanks.
Wiht the code you suggest, how should I declare the function in the header (.h) file ?
Please comments
Thanks
|
|
|
|
|
I have a simple dialog application. I wanna be able to run the application few times, but automatically the new dialog (application) sits on top of the previous. Is there anything I can do or set to make the new application hide behind the previous existing one instead?
|
|
|
|
|
Hi,
You can find the window handle of the previous instance then when you execute your second instance call the SetWindowPos Function[^] and assign HWND_BOTTOM.
If all of the dialog windows are children/siblings you may want to use the DeferWindowPos Function[^] instead.
Best Wishes,
-David Delaune
|
|
|
|
|
Wouldn't it make more sense to just limit it to a single instance?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
In Windows, you can do it using the WIN32API function SetForegroundWindow().
|
|
|
|
|
We need to create better installers for various products. We build professional products in Visual Studio using C++ and MFC, and we need to create installers for installation and upgrading, and for patches, and the installer needs to integrate well with the Fortress/Vault version control so that we can create patches for old releases. Some of our products require third party products to be installed, such as SQL Server/Express. Which are the current recommended products? InstallShield is the one I know. Any other professional grade products worth looking at? Thanks.
|
|
|
|
|
I know InnoSetup[^]. Never usede it myself but it is apparently very good.
|
|
|
|
|
|
Well I tried both the setups. The learning curve is long for them. If you want a quick solution then I will suggest InstallJammer. I like it.
http://installjammer.com/[^]
|
|
|
|
|
I strongly recommend Inno Setup[^]. It offers nice support for both simple, conventional installations (copy files, set registry values, register COM servers, etc.) and highly custom install tasks. It includes built-in scripting support, and you can easily call functions in external DLL's from script.
You mentioned SQL Server Express. I have an installer that loads SQL Server Express and its prerequisites (Windows Installer 3.1, MSXML 6, and .NET 2.0), creates an initial data base, and so on. I use Microsoft's redistributables in each case, and it takes about a dozen lines of script to install the whole mess.
The only disadvantage with Inno Setup, if you want to look at it that way, is that it does not create a Windows Installer MSI package. Enterprise users like MSI because it support installs pushed to client machines over a corporate network. My applications don't require this support, so it's a non-issue for me.
My experience with InstallShield has been poor. Before we went with Inno Setup, we bought a copy of InstallShield, which supposedly included support for localized installers. We spent just under $1,000 for this package. It took me two weeks to get a basic installer working, and at that it didn't reliably install our device drivers. I spent a significant portion of my time manually editing the MSI tables to fix bugs in InstallShield's crap. I then started looking at localizing the installer. It turns out the package we purchased required additional 'language packs' at $500 each to support translated installs. This was the last straw, as I needed a completed, working install, translated into several languages, Like Right Now. Based on a recommendation I saw here on CP, I tried Inno Setup. I replaced my InstallShield installer with an Inno Setup-based one in a single day.
|
|
|
|