|
I'm dumb founded at this.
I can't for the life of me figure out how to find out how much memory is being allocated for a vector.
I mean I want the actual number of bytes it is using in memory.
If anyone can help me with this, I'd be very thankful.
|
|
|
|
|
Anonymous wrote:
I'm dumb founded at this.
I can't for the life of me figure out how to find out how much memory is being allocated for a vector.
I mean I want the actual number of bytes it is using in memory.
If anyone can help me with this, I'd be very thankful.
sizeof() ?
|
|
|
|
|
Anonymous wrote:
I'm dumb founded at this.
I can't for the life of me figure out how to find out how much memory is being allocated for a vector.
I mean I want the actual number of bytes it is using in memory.
If anyone can help me with this, I'd be very thankful.
sizeof(data)*sizeof(vector) ?
|
|
|
|
|
int nSize = sizeof (vMyVector) + sizeof (vMyVector [0]) * vMyVector .capacity;
Please remember that this is TOTALLY implemtation specific and runs a very good chance of being wrong.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Assuming you mean std::vector then,
template < class T > size_t VectorSize ( std::vector< T >& v )
{
return sizeof ( v ) + sizeof ( T ) * v.capacity () ;
}
should give a good estimate.
std::vector< int > vi ;
std::cout << VectorSize ( vi ) << std::endl ;
vi.resize ( 100 ) ;
std::cout << VectorSize ( vi ) << std::endl ;
This produces,
16
416
on my system.
Does this help? It implies knowing a little about how the container is implemented, and isn't going to work for other than vectors. It's a good estimate for a vector since we know that the array part is contiguous.
Paul
|
|
|
|
|
Is to possible to receive the VC++ threads here as a mailing list and reply by that
mailing list in addition to this nice web based interface?
Thanks,
|
|
|
|
|
Anonymous wrote:
Is to possible to receive the VC++ threads here as a mailing list and reply by that
mailing list in addition to this nice web based interface?
No. This is a web only forum.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
i know how to get the command GetCursorPos working in vcpp but im having troubles porting to to borland cpp builder 6, it is giving me 2 odd errors. a simple example should do.
thank you
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
o nm, it was just a stupid clash of varibles, i was using "Mouse" for my point. So as to help others, i will post what i did
POINT MousePos;
GetCursorPos(&MousePos);
PopupMenu1->Popup(MousePos.x,MousePos.y);
Remember that this is for borland cpp builder and not vcpp, although it is basically the same...
ty
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
Just a stylistic point: if you're creating a popup menu in response to a mouse message, you typically want to create the menu where the pointer was when the mouse was clicked, not where it is now. You get this co-ordinate in the message's lParam (see for example WM_LBUTTONDOWN ). I'm not familiar with Borland C++ Builder, so I don't know how messages are processed in your application.
The exception to this is if you're handling a system tray icon notification message, where you don't get the parameters to the original message (and hence the location of the click).
You should use the message's cursor position because the user may have moved the mouse since clicking. If your application, or the system, is busy, this may cause the menu to appear somewhere different, which confuses the user.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi,
I want to implement the toolbar button to receive the dropped contents.
I am using COleDropTarget and I have registered that using m_DropTarget.Register(this). It works for a window, List control...But It doesn't work incase of toolbar buttons. Could anyone knows how to implement this?
Regards
Neha
|
|
|
|
|
I got lot of workspaces to be build... Is there any way i could build it from the command line, so that i can write a .bat file... There seems to be no make file or .mak file in my project directory
Thanx.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
You can run msdev from the command line and get it to do a compile and then exit. I can't remember what the command-line switch is, but you should be able to find it on MSDN. You just pass it your project file and the configuration you want to build, and it takes care of the rest.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanx a lot, just needed a pointer.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
It's /make . MSDEV.COM also understands the /? option to provide command-line help.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Go to C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Common\MSDev98\Bin and type msdev /? at the command prompt.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
thanx for the help, i got that part figured it out.. Now i got one more problem..
If in the batch file i am compiling more than 1 project... i want to stop the build if there is any error in the first build.
so i tried it like this.
msdev build etc.
if errorlevel == -1 goto processerror.
but now it goes to processerror in both cases (build with and without errors)
(yeah i got one warning in the build, i want to build it anyway)
is there any way i could stop the build process if there is an "error" in the build.
or am i asking too much
thanx.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Mr.Prakash wrote:
if errorlevel == -1 goto processerror.
You should be comparing errorlevel to 2 instead.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
humm, I will try that... but then the condition was satisfiing when i was comparing it with -1 then if i compare with 2 will never satisfy.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Then you need to compare against 0, which is the only non-error value. For example:
msdev.exe ...
if not errorlevel 0 goto processerror
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
It works fine, the above code when there is any compilation error. But if there is no compilation error of the .cpp files but if there is an error in compilation of the resource then the comparison fails and it goes forward as if the build was success
Thanx for the help anyways.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Using different scenarios, you might try printing the value of errorlevel at the end of each compilation. That way you'll know what conditions produce what results.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi,everyone.
Under WindowsXP,users can hide or show an application tray icon by customizing tray notification,but now i want to implement this in my application. i have tried some methods(such as using sysinternal's utilites - Regmon and Filemon ) to find how Windows Shell handles this,but the results disappointed me.
so can anyone know to do this ? use some undocumented windows shell api?
Thanks a lot!
|
|
|
|
|
Hello,
I've written a card game with all the bells and whistles, but I still have some learning to do. The problem is when I programmed it so that you see your first card, get a sound effect, a pause by the computer, then your next card, etc. Instead, you get five straight sound effects, a ton of pause, then all five cards pop up at once.
m_box01.SetBitmap(face[y]); soundfx(3); Sleep(250);
somewhere inbetween calling my soundfx subroutine and the Sleep function, I need to call something that will refresh the screen and show the card I displayed with SetBitmap. Something like an UpdateData or DoDataExchange kind of thing. I've made guesses until I'm blue in the face. Can anyone help?
thanks!
Dimenser
|
|
|
|
|
Call Invalidate() and then UpdateWindow .
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|