|
The "poor man's profiler" will find this one.
Steve
|
|
|
|
|
hi ,
I'm facing severe problem in erase method of STL in vc++6.0.
The code looks like below:
list<items> listItems;
list<items>::iterator iteBeg, iteEnd, itePrev;
getItems(listItems); //The function is defined in a DLL
for(iteBeg = listItems.begin(); iteEnd != listItems.end(); )
{
/*** processing ***/
//----more processing..
if(listItems.id == clientId)
{
itePrev = iteBeg;
iteBeg ++;
listItem.erase(itePrev); //=========== HERE IS THE ERROR "unhandled exception"
break;
}
//Some more processing;
iteBeg++;
}
I'm facing the erase method of the list class.
The list is filled by a function which is defined in a dll.
In debug mode, no problem at all. But I'm facing problem in release mode. I'm sure the dll (where getList() is defined) is also built in relase mode.
please correct my code, if somewhere I'm going wrong.
And in the msdn forums they specified STL in vc6 is terrible, and third party extensions are availlable. Please suggest me if any of such.
Thanks in advance.
Raja Pratap
|
|
|
|
|
Raj Prathap wrote: getItems(listItems); //The function is defined in a DLL
That's likely your problem. Depending on how the code is built (using a static vs. DLL version of the CRT), you may not be able to alloc memory in one module and free it in another. Filling in a list will alloc memory, obivously, so the erase will free it.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Dear Mike,
Could you please suggest us the way to resolve it. We have to fill the list in one module and the erase is called in another module.
If I write the destructor(int the header file for Item), does it solve the problem. Or there is no way ?. Please help us, its very to us.
And also, in debug mode we are not at all facing the problem.
Thanks in advance.
--
pratap
|
|
|
|
|
Firstly we can't see any "<" or ">" characters in your post. Secondly there is no formatting. Please consider the people who are donating their time to help you and take some time to make your question legible.
Try code like this:
-------------------
#include <list>
#include <algorithm>
struct items
{
int id;
};
class item_id_equals
{
public:
item_id_equals(int id) : m_id(id) {}
bool operator()(const items &item) const
{
return item.id == m_id;
}
private:
int m_id;
};
int main(int argc, char* argv[])
{
using namespace std;
typedef list<items> colletion_t;
typedef colletion_t::iterator collectionIter_t;
colletion_t ItemList;
// Fill the list here...
collectionIter_t e = ItemList.end();
collectionIter_t i = find_if(ItemList.begin(), e, item_id_equals(5));
if (i!=e)
{
ItemList.erase(i);
}
return 0;
}
Steve
|
|
|
|
|
Thank you Steve for your reply.
Sorry, but while posting the "<" and ">" I have included.
I'll definitely take care of formatting in my future posts.
--
pratap
|
|
|
|
|
i done a project on time i have a combo box in that we have different countries once we select the coutry,then we will show the corresponding time.
it's work well.but problem is
one we execute the project and if we change our system time then in my project also changing
plaese help me,
thank u for read,
sree.
|
|
|
|
|
Are you using CTime::GetCurrentTime that returns the current system time
Then you would be converting that time to GMT Time or something else.
Right?
So when you are changing the system time, the change is reflected for the other time zones.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
thnak u.
i have done the same.
so how can i rectify this.
ram.
|
|
|
|
|
So what exactly is the problem?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i am developing a project that includes chart.. dow do i generate charts using vc++ ?? pleaase help me.. i am using PGL ligrary... what is the procedure?
-- modified at 2:03 Friday 30th June, 2006
|
|
|
|
|
I developped a chart control. Take a look at the link in my sig if you are interested.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
hello
can i include ur link in my code.. if i can ,please tell me the procedure..
thanks..
regards
sriv
|
|
|
|
|
sriv_18 wrote: can i include ur link in my code..
What do you mean ??
Did you take a look at my article ? Everything is explained quite in detail.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
|
Lets say, i have this simple dialog box, with a "load picture" button (which i've got it working), with a few clicks, the picture is able to be displayed in the frame. Afterwhich, -=Here Comes My questions=- how do i encrypt the picture and displaying it with the original image side by side?? (The frames are there side by side just that i do not know how to encrypt and display it ) Afterwhich, how to i save it? so That i can load it for decryption?? Please help me thanks
Thanks
-- modified at 1:57 Friday 30th June, 2006
|
|
|
|
|
Any one have sample application creating Message queue using MSMQ. Pls give details if u hav. Thanks in advance.
Rin
|
|
|
|
|
SeeHere[^]
maybe it is some helpful to you
whitesky
|
|
|
|
|
hi !!
I am facing some problem retrieving size of a string from string Table. I am using FindResource() function to get handle for the resource.
I refered MSDN and get to know that String Table is stored as a block of memory of 16. Thus FindResource() will always give me address of that block. I am successfully retrieving handle to the block where the desired string is present.
The problem is I know at which place/ index the string is present in that block. But dont know how to retrieve it!! I want to get its size.
Can somebody plz help me on this!
Thx in advance
I am posting the code here
LPSTR GetErrorString(UINT uiStringId)
{
int iRetVal=0;
DWORD dwResSize=0;
char temp[10];
HRSRC hRes;
DWORD nID = (uiStringId >> 4) + 1;
DWORD nitemID = uiStringId % 0x10;
hRes = FindResource(gl_hModule,MAKEINTRESOURCE(nID), RT_STRING);
dwResSize=SizeofResource(gl_hModule,hRes);
....
...
..}
|
|
|
|
|
Why don't you try LoadString, that would be more comfortable for loading string resources.
|
|
|
|
|
Thx for the reply!
Actually I want the size of the string before calling LoadString().
This will allow me to allocate memory dynamically for that string.
|
|
|
|
|
sach!! wrote: This will allow me to allocate memory dynamically for that string.
It would be less troublesome to just allocate a (slightly) bigger-than-necessary buffer.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Hi,
I have two unicode text files. Each file contains different SymbolicID's with corresponding messages. Now I want to replace the a line of text in the second file of the corresponding symbolic name is found in the first file. So kindly help me anybody,
how to replace a line with files using VC++.
Thanks & Regards
knarasimharao
knarasimharao
|
|
|
|
|
iam adding the file into the listbox and also iam adding all the files in the folder using below code
CString csFolderSelected;
BROWSEINFO bi = {0};
bi.ulFlags = BIF_RETURNONLYFSDIRS ;
LPITEMIDLIST pIt;
if( (pIt = SHBrowseForFolder( &bi )))
{
TCHAR tcPath[ MAX_PATH ];
if( SHGetPathFromIDList( pIt, tcPath ))
csFolderSelected = tcPath;
}
TCHAR lpszOldPath[MAX_PATH];
::GetCurrentDirectory(MAX_PATH, lpszOldPath);
::SetCurrentDirectory(csFolderSelected);
m_list7.Dir(DDL_READWRITE|DDL_DIRECTORY, _T("*.mp3"));
::SetCurrentDirectory(lpszOldPath);
but problems i want to add the files with path but it is aadding only name of the file in the folder,
please help.
|
|
|
|