|
Well we are both agreed on the fact that you shouldn't mix and
match the memory. The extra functions and data members you
refer to will also cause data offsets and possibly the virtual
function table to be at a different location than expected.
Defintely bad news.
If you intentionally link a release DLL to a debug DLL of course
the user will get problems if they mix and match the objects and
code.
The reason for my post was to point out that if you link against the DEBUG DLL you won't accidentally be calling the functions in
the release DLL, even if that release DLL is in the process. You have to go out of your way to link the wrong DLL, and in that case, well, you need to change your link options.
I have a project at present which intentionally loads the Release MSVCRT.DLL into a running program, be that program debug or release. It doesn't crash the running program because the only
code calling the release MSVCRT DLL is the code I injected into
the program. In the case that the running program is Release then
we both share the MSVCRT.DLL heap, which is allowed for in the design of MSVCRT.DLL as long as you are using the DLL and not linking statically.
Stephen Kellett
|
|
|
|
|
I have a large custom database that I'd like to search for keywords. Anyone know of anything I could use that is ultra-fast?
|
|
|
|
|
you need to scan the files and build an index(s) of the keywords ... like a web search engine ... then finding keywords is a snap
suggest you build a file of the keywords you want to define or a file of non-keywords you want to ignore and then use that to build the index of the stuff in the db
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
what is the difference betweeen delete
and delete []
|
|
|
|
|
If you allocate an array with new, you use delete [] when you free the memory.
--Mike--
http://home.inreach.com/mdunn/
This must be Thursday. I never could get the hang of Thursdays...
|
|
|
|
|
But delete and delete[] both seem to generate the same assembly output, so is there really a difference ?
|
|
|
|
|
They may look the same, but they're not.
For instance, take this simple application:
#include "stdafx.h"
#include <iostream>
using namespace std;
class a
{
public:
a(){};
~a(){cout << "a::~a()\n";};
};
int main(int argc, char* argv[])
{
a *pa = new a[10];
delete [] pa;
cout << "------" << endl;
pa = new a[10];
delete pa;
return 0;
}
If your theory were correct, it would output 10 a::~a()'s followed by dashes and 10 more. Instead, this is the output:
a::~a()
a::~a()
a::~a()
a::~a()
a::~a()
a::~a()
a::~a()
a::~a()
a::~a()
a::~a()
------
a::~a()
As you can see, the destructor gets called 10 times when using delete [] and only once when using delete.
|
|
|
|
|
Delete[] is necessary for deletion of objects. I mean instances of classes.
Objects in array should be garanteed to destruct itself and free resource.
Delete[] calls all of destructor of objects in array and call of destructor
calls destructor of base class's destructor.
So delete[] gaurantees destruction of all object in array .
For primitive types like int, long, char etc..
You don't have use delete[] for freeing resource.
Delete is enough. But this is only the theory..
In practice,I recommend to use delete[] whenever you're freeing resource in array.
Cause it makes code more clear and readable.
It looks to clear to other developers who are seeing your code or youself in future.
Regards,
Ryan
|
|
|
|
|
Okay, this is kinda weird ...
I'm going to simplify it (but still show problem)
=================================================
char *ModuleList[10];
char *strInput;
char buffer[80] = {80};
bool bDone = false;
int iLoop = 0;
while (!bDone)
{
strInput = _cgets(buffer);
if (strcmp(strInput, "exit") == 0) { bDone = true; }
else
{
ModuleList[iLoop] = strInput;
iLoop++;
}
}
Now yeah iLoop will go higher than 9 that will cause an error .. but the problem is that the ModuleList array does this:
Input: test
ModuleList[0] == test;
ModuleList[1] == "";
..
Input: again
ModuleList[0] == "again";
ModuleList[1] == "again";
ModuleList[2] == ""
..
See what I mean? why does it change the previous values in the array instead of leaving them alone? The array seems to get screwed up when the strInput = _cgets(buffer); line gets called.
Any help here is much appreciated .. probably some stupid mistake, but I'm a little lost here
Thanks, Travis
|
|
|
|
|
strInput is always has the same value (buffer+2). so, you are setting the same pointer value into each ModuleList element.
-c
|
|
|
|
|
also the line char buffer[80] = {80}; should read char buffer[82] = {80};
just a small point
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Where you have:
char *ModuleList[10];
it is NOT an array of strings!!
It is actuall an array of string pointers.
So where you go:
ModuleList[iLoop] = strInput;
what you actually doing is setting all of the string pointers in the array to
point to the same string. The same string that you change every time around
the loop.
So if you really want to store the strings try:
char ModuleList[10][80];
and
(void)strncpy(ModuleList[iLoop], strInput, 80-1);
ModuleList[iLoop][80] = NULL; // to guarentee NULL termination.
// in stead of ModuleList[iLoop] = strInput;
Hope that helps.
Jules
|
|
|
|
|
Thanks for the help from you 3, helped a lot and I have it working now =)
- Travis
|
|
|
|
|
I want to learn how to program a simple Databases.
What Database can i learn most from when am new??
I was thinking of making a simple text in a editbox and save it on a base,
where do i start??? Thank you
|
|
|
|
|
<<< In the name of GOD >>>
Hi.
I want to get string from Owner-Draw ListBox :
void CHlistbox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CString string;
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rc = lpDrawItemStruct->rcItem;
UINT action = lpDrawItemStruct->itemAction;
UINT state = lpDrawItemStruct->itemState;
UINT index = lpDrawItemStruct->itemID;
if(action & ODA_DRAWENTIRE)
{
GetText(index,string);
pDC->FillSolidRect(rc,RGB(0,0,0));
pDC->SetTextColor(RGB(100,100,50));
pDC->TextOut(rc.left+1, rc.top+1, string); // PROBLEM IS THERE
}
}
Adding string with ListBox :
void TestDlg::OnOK()
{
m_listbox.AddString("Hadi Rezaie");
}
My other problem is when i added 1 string, i cant adding other string with ListBox.
Please help me ...
Hadi Rezaie
|
|
|
|
|
Is there a way to get a handle or a pointer to the scroll bar in a CListCtrl ?
Is there a way to disable and make the scroll bar in the CListCtrl class not appear?
Death reaches all
Your time will come billy boy
Eyal
|
|
|
|
|
Hallo everybody! I'm developing an application with other people and we are using components.
I'm developing some components and I would like to know if someone know if it's possible (or how) to choose dynamically the ID for the new component at runtime.
Thanks
Bye bye
Nicola
|
|
|
|
|
as far as i know the resource id's are a compile time thing that you would have a real hard time changing at run time ... its important to understand the difference between compile time and run time ... what you can and cant do
unless of course i dont understand what i'm talking about
always possible
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
You need to get with your fellow developers and standardize on a method to generate ID's. Basically, all you need to do is make sure that you don't duplicate the same number on the same dialog. One way to do this is allocate a range of ID's that you never use for static resources, and then create a function to allocate the ID's at runtime, which is simply a counter that returns a new number in the range everytime it's called.
|
|
|
|
|
First, I think you read this writings.
I want to know how to get ip address and customer id(client id).
so, I want to put in data(CString variables) value made from above structure.
I don't know this at all.
Please reply this question quickly.
Please... Please...
|
|
|
|
|
WSADATA wsaData;
struct sockaddr_in sock;
CString strHostname;
int lLen = 255;
WSAStartup(0x0101, &wsaData);
gethostname(strHostname.GetBuffer(lLen), lLen);
HOSTENT * lpHost = gethostbyname(strHostname.GetBuffer(lLen));
memcpy(&(sock.sin_addr), lpHost->h_addr_list[0], lpHost->h_length);
TRACE2 ("Host Name: %s IP address : %s\n",strHostname, inet_ntoa(sock.sin_addr));
WSACleanup();
Considderd to be the worlds fastest knoppenbonker.
10 Months of working experience with the worlds fastest copie paster(about 2000 lines a minute).
And experience with the one and only NewEra Guru.
|
|
|
|
|
I'm using CDataSource, CSession etc to work with some database.
This database is having, for example, one table with two columns.
One is a self-incrementing counter (index) and other is a value.
My task is to write a function like this:
long Add(long val) {
return index_of_val_added;
}
I'm doing it this way:
long Add(long val) {
CCommand< CAccessor< table > > t;
t.Open(session, "insert into table(val) values(-1);", NULL, NULL, DBGUID_DEFAULT, FALSE);
t.Close();
t.Open(session, "select * from table where val=-1;");
int id = t.m_id;
t.Close();
CString s;
s.Format("update table set val=%d where id=%d", val, id);
t.Open(session, s, NULL, NULL, DBGUID_DEFAULT, FALSE);
t.Close();
return id;
}
I know, that it is ugly... Could anybody show me the correct way to do it?
With the best regards, Vitaly.
|
|
|
|
|
I have a JPEG image to be printed onto the printer.How to this is possible in Windows NT
Raja sekhar
|
|
|
|
|
Use one of the classes available online ( like www.paintlib.de ) to load the image, then you'll be able to print it just like a BMP.
Christian
|
|
|
|
|
I've defined a private message in my MainFrm.h as below:
#define UWM_USER_APPLY WM_APP+17
afx_msg LRESULT OnUserApply(WPARAM wparam, LPARAM lparam);
In MainFrm.cpp, I've added this within the message-map macro:
ON_MESSAGE(UWM_USER_APPLY,OnUserApply)
I've created a property sheet, when user press "Apply" button, I do the following:
void COptionSheet::OnApply(){
GetActivePage()->UpdateData();
HWND hwnd=AfxGetMainWnd()->m_hWnd;
::SendMessage(hwnd,UWM_USER_APPLY,(WPARAM)this,0);
m_pg1.SetModified(FALSE);
m_pg2.SetModified(FALSE);
}
It work fine at debug version, when I build the release version, it'll cause "illegal operation" at the line:
::SendMessage(hwnd,UWM_USER_APPLY,(WPARAM)this,0);
If I simply changed it to a standard WM_, it'll work. For example:
::SendMessage(hwnd,WM_ENABLE,(WPARAM)this,0);
I'm using Visual C++ 6.0 with SP4 on Win98. I've tried both in NT and Win98, both have the same bad result.
Please help. Thanks in advance.
|
|
|
|