|
If your 'my_struct' can remain 20 bytes then the following works for variable 'C', I don't recommend any type of container since the overhead of managing it and implementing 'operator[]' is probably going to be significant.
The total allocation is 180MB, this is much less than commonly fitted as main RAM to modern PCs so the quantitiy per se isn't too much. You do need to consider how you access it in order to work with the CPU data caches rather than against them, but without knowing what you do to the data I can't help there.
struct my_struct
{
char buff [ 20 ] ;
} ;
typedef my_struct my_struct_array [ 30 ][ 10 ][ 10 ][ 3 ] ;
const unsigned my_arr_size = 1000 ;
int main()
{
my_struct_array * my_arr = new my_struct_array [ my_arr_size ] ;
for ( unsigned a = 0; a < my_arr_size; ++a )
for ( unsigned b = 0; b < 30; ++b )
for ( unsigned c = 0; c < 10; ++c )
for ( unsigned d = 0; d < 10; ++d )
for ( unsigned e = 0; e < 3; ++e )
{
my_arr [ a ][ b ][ c ][ d ][ e ].buff [ 0 ] = '0' ;
my_arr [ a ][ b ][ c ][ d ][ e ].buff [ 19 ] = '9' ;
}
delete [] my_arr ;
return 0;
}
Paul
|
|
|
|
|
So good. I found an idea to solver my problem based on your code.
Thank you very much.
I will post more thread in this forum. If you see, help me.
|
|
|
|
|
hay all
can any one tell me What is hash table how can i use it in a clint server aplication
|
|
|
|
|
I suggest :-
1) learn how to spell/type
2) following this link http://www.brpreiss.com/books/opus4/html/page203.html[^]to learn about hash tables in general
3) doing some google searches to get the basic questions out of the way.
The answer to Princess Anastasia wrote:
how can i use it in a clint server aplication is 'boundless' - since you provide no useful information that would allow someone here to help you.
There are also client-server examples here on CP, try looking for them and see if they meet the criteria you're looking for.
4) most people won't respond to your question because it sounds like a 'homework'/'assignment' question - if you do have such, and want an answer, then try posting some code that proves you've at least attempted something for yourself.
Sorry to be harsh
Garth
|
|
|
|
|
Good Reply. 5!
God is Real, unless declared Integer.
|
|
|
|
|
A Hash Table is a data structure where you input elements by a key value. Even though the other response you got was horribly rude and unwarranted, he was right that you should probably look it up to determine how you might want to write this table. They can be as simple as an array, and as complex as multi-dimensional arrays with lists, or whatever. If you plan on putting a lot of elements into your table, you should probably read up on MSDN about efficiency in design. If you use dynamic memory in your hash table (which you probably will), then you will most likely be causing the operating system to page fault as it passes between links. If this is the case, then while a hash table is supposed to be fast, it will actually be no better than a linked list.
After you get a hash structure, you can use it to store socket connections. You've probably got a lot of reading to do to be ready to design this application.
And ignore it when you get somebody responding like you've done something wrong by asking a question. Some people forget that these forums are set up for asking questions and getting advice.
|
|
|
|
|
I'm sorry if you think my reply was rude and unwarranted - I'm not an a**ehole, despite appearances, and, I definately havnt forgotten that these forums are set up for asking questions and getting advice (else how myself would I have learnt anything, except by the generosity of the people here)
rude - no, I was more polite than a lot of people can be - you should see the typical reply to some such questions - at least I gave a pointer to some info on hash tables - good work from you to point out how they may be used in a client-server situation.
unwarranted - depends on how many times you've done someones homework for them I guess - Im quite prepared to help people, when someone has tried to do some pre-reading, and info on hash tables per se is available all over the net ..
I'd prefer to try to teach a person how to fish, rather than spoon feed them.
I'll accept your criticism - maybe next time my response will be different.
may your god go with you.
Garth
|
|
|
|
|
Garth J Lancaster wrote:
...info on hash tables per se is available all over the net ..
Keep in mind that not everyone is as net-savvy as yourself. They may have simply stumbled upon the CP site, or linked to it from the school's site. In any case, you can't assume that everyone knows about Google, Jeeves, Yahoo, MSDN and other search engines. Adhere to the "Teach a man to dish..." proverb and leave the criticism at home.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
hi,all:
i create a service,and my service must depend on two other service.
in function CreateService():
SC_HANDLE CreateService(
SC_HANDLE hSCManager,
LPCTSTR lpServiceName,
LPCTSTR lpDisplayName, // pointer to display name
DWORD dwDesiredAccess, // type of access to service
DWORD dwServiceType, // type of service
DWORD dwStartType, // when to start service
DWORD dwErrorControl,
LPCTSTR lpBinaryPathName,
LPCTSTR lpLoadOrderGroup,
LPDWORD lpdwTagId,
LPCTSTR lpDependencies, // pointer to array of dependency names
LPCTSTR lpServiceStartName, // pointer to account name of service
LPCTSTR lpPassword );
the Parameters of lpDependencies means:
lpDependencies
Pointer to a double null-terminated array of null-separated names of services or load ordering groups that the system must start before this service. Specify NULL or an empty string if the service has no dependencies. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all members of the group.
You must prefix group names with SC_GROUP_IDENTIFIER so that they can be distinguished from a service name, because services and service groups share the same name space.
but i don't know how to do?who can give me a example.
appreciate any help!!!
|
|
|
|
|
I have a problem,
I am trying to write a function that reads a file, maipulates the data inside and then call it to the main() for an output.
okay the question looks something like:
1. There is a file say "filee.dat" it has 5 columns of numbers 1st column from 0 to 300. the rest correspond to it. 1st column is time,, the next is distance, the thrid is speed etc.
The thing is i need to write a function that calls this file and finds the time at which the distance starts decreasing (i.e the car is going forward but then after one high point, starts going back (so the distance decreases)).
SO from the main the output should be the time that corresponds to the the point where the distances starts to decrease.
Thansk!!
|
|
|
|
|
the file must have some structure.
a) the columns has a fixed size
b) the date is delimited with a special char maybe a ;
so yu have to read your file in a way, you can access the different values.... depending on the layout of your file.
|
|
|
|
|
so what would the code look like? there are columns for t,z,v,a and at places there are no values the but it goes from 0 to 300 with an interval of 0.5
the code is the thoing i am not clear of as in how to read it and how to acces the desired values.
|
|
|
|
|
no idea can anyone else help her?
|
|
|
|
|
not necessarily.
if each line looks like this : 50 312 125 423 12 , you can easily read each entry (line) with a cin-like call.
<font style="color:blue;">int</font> id, speed, distance, time <font style="color:green;"> </font>;
file >> id >> speed >> distance >> time <font style="color:green;"></font>;
you now have all your values read in one line.
TOXCCT >>> GEII power
|
|
|
|
|
I am trying to avoid setting up the security auditing for each and eveyr PCs. Is monitoring the security event log the only way to do it? Any help is appreciated.
|
|
|
|
|
NetUserGetInfo() will return NERR_UserNotFound if the user account has not been created.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi David,
Thanks for the info. I think NetUserXXX suite of functions (including NetUserGetInfo and NetUserEnum) are for getting info about an existing resources. These functions maybe useful to poll against if a user has connect to your PC (this itself is a very useful info for my other project! Many Thanks!). However, having said it, I need to monitor in real time if any user a/cs has been created or modified. My aim is to protect against intrusion. As I have said, I could monitor the security event but I would need to set the auditing policy on each and every PCs (which I dearly would want to avoid the extra admin work).
More ideas?
|
|
|
|
|
hello i have a simple problem that i need to solve. i need to create a file, programmaticaly, with certain text. I am not sure if you can use static const char, but this is why i am asking. If anybody knows how to do this please help
I know i have to use CreateFile and WriteFile api but i need code that uses this
-Ryan M.
|
|
|
|
|
Ryan McDermott wrote:
need to create a file, programmaticaly, with certain text
Use WIN32 File I/O API functions CreateFile and WriteFile for this purpose.
Ryan McDermott wrote:
I am not sure if you can use static const char
Yes you can.
Gurmeet S. Kochar If you believe in God, it's because of the Devil
My CodeProject Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
#include <iostream>
#include <fstream>
bool WriteTheFile ()
{
std::ofstream ofs ( "MyFile.txt" ) ;
if ( !ofs )
return false ;
ofs << "My file contains this text" ;
return true ;
}
Since the data is copied out to the file any text that is valid at the time of the write (in this case the '<<') can be written.
IMO if you're writing in C++ then it's worth becoming familiar with the iostream part of the Standard Libary and reserving direct use of the Win32 API for special cases where you really need something non-standard.
Paul
|
|
|
|
|
Hi,
I'm currently experiencing quite an odd problem.
I have this dialog (CDialog) which, among other things, contain a tree control and a property sheet. That is, I create the CPropertySheet dynamically by doing something like this:
<br />
m_interactionSheet.Construct("HEHE", this);<br />
<br />
m_actionPage.Construct(IDD_ACTIONS);<br />
m_eventPage.Construct(IDD_EVENTS);<br />
m_interactionSheet.AddPage(&m_actionPage);<br />
m_interactionSheet.AddPage(&m_eventPage);<br />
<br />
m_interactionSheet.Create(this, WS_CHILD | WS_VISIBLE);
The above code works without any problems. However, if I try to show another dialog after having called CPropertySheet's Create() function, the application locks up. It's like it goes into an infinite message loop or something :S
If I comment out the m_interactionSheet.Create() part I can create and display CDialogs again.. otherwise not.
EDIT: I have reproduced the behaviour in an ordinary SDI application. PLEASE have a look at it here:
http://www.blacksmith-studios.dk/PropertyTest.zip[^]
The problem is in the CInteraction::OnInitDialog() function. (BTW, this is just a test program so everything might be messy and all.. this problem is just killing me )
Any idea what might be causing this as I'm all blank
Thanks,
|
|
|
|
|
m_actionPage
m_eventPage
are these member variables of type CPropertyPage or a class derived from PropertyPage.
If so , i dont think construct is required, you can remove all three calls to constructs.
Then try. see if it works.
God is Real, unless declared Integer.
|
|
|
|
|
Hmm.. you're probably right about the Contruct() thing since both m_actionPage and m_eventPage are classes derived from CPropertyPage.
However, it didn't work. The application still locks up if I try to display another dialog.
I did observe something strange though. If I comment out the m_actionPage part and only go for the m_eventPage part, everything works :S
I did just discover, however, that if I put controls on the property page dialog template THEN it locks up again.
What the hell is going on here?
|
|
|
|
|
humm, things are going out of my hand now, did you enable the propertypage as popup window.
God is Real, unless declared Integer.
|
|
|
|
|
Yes, no difference there
Do you mind if I add you to my MSN contact list? Just so we can discuss this more directly (if you have the time and want to, of course )
Thanks for your time so far!
|
|
|
|