|
I want to know how to declare three dimensional arrays in C/C++ and how they work. Examples will do. Please help.
|
|
|
|
|
Maybe this link[^] will help get you started.
|
|
|
|
|
I have been to that site but it only talks about it without examples. I know it can for instance be declared as follows:
int rates[10][4][3];
The declaration is what has been shown on the site. But I want to know how to initialise the array when it is declared, and know how the indexing will refer to a particular value in the initialising list.
|
|
|
|
|
OK, how about this[^] site.
|
|
|
|
|
Try the information here[^]. Although this only covers 2D arrays, you can think of the third dimension as a number of 2D arrays one on top of the other, the index increasing as you go further down the planes.
It's time for a new signature.
|
|
|
|
|
Dan_K wrote: But I want to know how to initialise the array when it is declared...
Like:
int Array3D[2][4][6] =
{
{
{ 1,2,3,4,5,6 },
{ 7,8,9,10,11,12 },
{ 13,14,15,16,17,18 },
{ 19,20,21,22,23,24 }
},
{
{ 77,78,79,80,81,82 },
{ 83,84,85,86,87,88 },
{ 89,90,91,92,93,94 },
{ 95,96,97,98,99,100 }
}
};
"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
|
|
|
|
|
|
A sample;
int array[3][4][5] = {
{
{ 1, 2, 3, 4, 5 },
{ 1, 2, 3, 4, 5 },
{ 1, 2, 3, 4, 5 },
{ 1, 2, 3, 4, 5 }
},
{
{ 1, 2, 3, 4, 5 },
{ 1, 2, 3, 4, 5 },
{ 1, 2, 3, 4, 5 },
{ 1, 2, 3, 4, 5 }
},
{
{ 1, 2, 3, 4, 5 },
{ 1, 2, 3, 4, 5 },
{ 1, 2, 3, 4, 5 },
{ 1, 2, 3, 4, 5 }
}
};
|
|
|
|
|
In fact Ive called ShellExecute() to execute another application when clicking on the button on the dialog. And I want to suspend the current dialog until the app executed by ShellExecute() finishes its tasks. But I dont know how to do it. Can anyone help? Thanx in advance.
PS: I dont know whether WaitForSingleObject() will work.
|
|
|
|
|
If you WaitForSingleObject on the handle of the spawned process the thread doing the waiting will stop until the spawned app completes.
To get the process handle it might be an idea to use ShellExecuteEx as you can find out the handle of the spawned process a bit easier.
Cheers,
Ash
|
|
|
|
|
|
int RunAppAndWait(char *cmd)
{
PROCESS_INFORMATION ProcInfo;
STARTUPINFO StartInfo;
int exit_status = 0;
memset(&StartInfo, 0, sizeof(StartInfo));
StartInfo.cb = sizeof(StartInfo);
if (CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &StartInfo, &ProcInfo))
{
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcInfo.hProcess, (unsigned long *)&exit_status);
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
return exit_status;
}
return 1;
}
|
|
|
|
|
|
Hi, I have some data in char *szBuffer. I need to read the data fom the buffer nad put them into respected variable.
Suppose szBuffer returns "15,30\r\n CMD OK \r\n" , then I need to keep 15 in one variable,30 in other and CMD OK in other variable.
Can anyone help me how to do this. Any sample code will be good help for me.
Thanks..
|
|
|
|
|
Read up on tokenizing. See strtok() and strchr() for starters.
"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
|
|
|
|
|
The standard library is your friend if you're using C++. Have a look at:
- istringstream
- getline
and see what you can cobble together.
Cheers,
Ash
|
|
|
|
|
Can u please provide some sample code, I m very new in c++.
Thanks
|
|
|
|
|
We don't do homework around here. You have been given enough hints of what to use and read up on. Try to get something wotking. If you then have problems, post your code and explain what does not work. Someone will try to help you out.
Dave.
|
|
|
|
|
Hi
I want to get the column names in CListCtrl. Can any one show me the code for it.
|
|
|
|
|
Did you try the GetColumn() method?
"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
|
|
|
|
|
I have made my own XML format which looks a bit like HTML, but I need a browser to read it. The built in browser windows in Visual studio can't read it, so I need to make a simple XML reader that displays the XML like HTML. Is there any very simple open source project I could edit, or is there a simple way to make an XML reader from scratch? Help would be appreciated
|
|
|
|
|
You can use the Microsoft MSXML[^] tools, or try a Google search for open source alternatives.
It's time for a new signature.
|
|
|
|
|
|
if it follows XML standards, then most (all?) broswer will be able to read it; it might not be able to understand the tags and their meanings (how to display them), see : http://msdn.microsoft.com/en-us/library/ms754529(VS.85).aspx[^]
You will need to create some sort of stylesheet to help display your XML files.
Watched code never compiles.
|
|
|
|
|
I will give you a simple example of what I'm trying to do:
Text in here will be displayed as normal, but <my own="" tag="">text in here will have a new formatting
Is there a way to make a "browser" that reads this kind of markup instead of HTML?
|
|
|
|
|