|
HI Mohan,
function FreeExtra():
Frees any extra memory that was allocated while the array was grown. This function has no effect on the size or upper bound of the array
function SetSize():
Use this function to set the size of your array before you begin using the array. If you do not use SetSize, adding elements to your array causes it to be frequently reallocated and copied. Frequent reallocation and copying are inefficient and can fragment memory
...referenced from MSDN oct 2001
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
With SetSize your code runs faster - memory for 1000 items is allocated and not copied\extended during adding new items. Without it array will allocate new memory several times, copying all items to new location.
FreeExtra just free unused memory - but it have to copy whole array to new location, which cost time. So I almost never use it - if you will want to add new item afterwards, you will cause array to copy items again.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
Igor,
I kinda got a clue, thanks. But i got a question...
I load the array only once when my application loads & then i just use it for reference purpose only, in this case if i include SetSize(0,1000) & the array loads only 500 items, will that mean the memory for other 500 still exists & not released?
Thanks.
Mohan
|
|
|
|
|
|
can anyone teach me how to get string input and display it in the blackbox?
fe8her
|
|
|
|
|
Prinz Ryoiji wrote: it in the blackbox?
Is this a Console Application?
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
yupe..
win32 console application..
|
|
|
|
|
That blackbox is called console.
Well I wrote an example for you and then I lost the whole thing (Page cannot be displayed).
Well CG has done that for you...
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
owh..ok..
thanks...
|
|
|
|
|
Nibu thomas wrote: That blackbox is called console.
Also called "DOS-Box" in some books ...
Maxwell Chen
|
|
|
|
|
owh..ok..
thanks a lot!
|
|
|
|
|
You can change the black box to green box...
Just add this line of code
system("color 2f"); :->
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
Nibu thomas wrote: change the black box to green box...
Maxwell Chen
|
|
|
|
|
|
Nibu thomas wrote: Color 2f
Yeah, I know. I was trying to show you a green face. ;P
Maxwell Chen
|
|
|
|
|
|
The readme says: The first nibble for the BK color, and the second nibble for the foreground color.
Value F = Bright White.
But when I issue color FF , it resets to system color!
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: But when I issue color FF, it resets to system color!
Both BG and FG cannot be the same. Try FA or 2F and then FF . Nothing happens.
Use Color without any parameters to restore to default.
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
Nibu thomas wrote: and then FF. Nothing happens.
You're right!
Maxwell Chen
|
|
|
|
|
#include <string>
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main()
{
string s;
cout << "Enter your name: ";
cin >> s;
cout << endl << "Your name is " << s << endl;
cout << "Press enter to end this wonderful journey";
cin >> s;
}
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
I'm after C++ examples of how to allow the user to record mouse and keyboard events inside an application. The recorded events can then be saved to a file so that they can be play-back at a later date. A macro facility in other words. Can anyone help me with this? I'm using Visual C++ 6. .
Thanks lots.
Choppa
|
|
|
|
|
Chopper Dang wrote: I'm after C++ examples of how to allow the user to record mouse and keyboard events inside an application.
It's a long story. Take a look at WH_JOURNALRECORD and WH_JOURNALPLAYBACK . Kyle Marsh has written an interesting article on Hooks . Look up that in MSDN .
Chopper Dang wrote: then be saved to a file so that they can be play-back at a later date
Well I am not sure about saving it to file!
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
Thanks for your reply Nibu. I'm actually looking for events within my own application (very much like in MS Office apps). WH_JOURNALRECORD and WH_JOURNALPLAYBACK seem to record every event that happen within the system, and I dont know how to filter them out.
|
|
|
|
|
Chopper Dang wrote: I'm actually looking for events within my own application (very much like in MS Office apps).
Maybe you can tweak them a bit to suit your needs.
Or try these functions to find out what's happening and log these into a file and later through code play them back...
GetCurrentMessage
PeekMessage
GetQueueStatus
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|