|
DavidCrow wrote: I'd be more concerned with this at the moment than I would be with why my code does not work. If you can't debug effectively, it's going to be a long road...
Wrong :/ i was on Release mode
When i put breakpoint in the for {loop} so i get the compare value it give me a Debug error and while i press (ignore it) it doesnt
|
|
|
|
|
Immunity18 wrote: ...it give me a Debug error...
I assume you are referring to a debug assertion on the line containing isalpha() . If so, it should be apparent why this is happening. The first time through the loop, index is 0, and you are then passing -1 to the GetAt() method. Do you concur?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
in first i didnt have control it right and for index = 0 i passing -1 in getAt but now i think its right the code ? but still same debug assertion
int nCount = 0;
int index=0;
for (int i = 0 ; i < line.GetLength() ; i++)
{
index=line.Find(str2,index);
if( index!= -1 )
{
if ( index >1 )
{
if( 0 == isalpha(line.GetAt(index-1)) && 0 == isalpha(line.GetAt(index+ str2.GetLength())))
{
nCount++;
index++;
}
}
else
{
if(0 == isalpha(line.GetAt(index+ str2.GetLength())) )
{
nCount++;
index++;
}
}
}
else
return nCount;
}
return nCount ;
|
|
|
|
|
See here.
You indicate that the debug assertion is still happening, but you failed to indicate where, and what the call stack looked like at that point.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Immunity18 wrote: althought the results are differect
And those results would be what? Are you stepping throuygh the Compare() method? I doubt it, or would would have quickly seen that the last time through the loop, index is 30, which results in 33 being sent to the GetAt() method. Since the line being examined is only 33 characters long, the valid indices are 0-32.
Again I ask, what are you trying to accomplish with the code following the call to Find() ?
Immunity18 wrote: http://195.251.111.53/~labdb219/upload/correctvalues.bmp[^]
Try using a JPG so that a 2.3MB image does not have to be used. What exactly is this supposed to be showing? "How" you are calling the Compare() method is not the problem. It's what you are doing within it that is.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
sorry about that. Well yes i did put a breakpoint inside Comare()
but it dont return me values (and .exe doesnt minimized)
still i have this error debug assertion link[^]
and my compare code is link[^]
int CInfoRecoverDlg::Compare2(CString line, CString str2)
{
int nCount = 0;
int index=0;
for (int i = 0 ; i < line.GetLength() ; i++)
{
index=line.Find(str2,index);
if( index!= -1 )
{
if ( index >1 )
{
if( 0 == isalpha(line.GetAt(index-1)) && 0 == isalpha(line.GetAt(index+ str2.GetLength())))
{
nCount++;
index++;
}
}
else
{
if(0 == isalpha(line.GetAt(index+ str2.GetLength())) )
{
nCount++;
index++;
}
}
}
else
return nCount;
}
return nCount ;
}
|
|
|
|
|
Immunity18 wrote: still i have this error debug assertion link[^]
So have you clicked on the Retry button, and then the Call Stack button? That'll show you exactly what the problem is, just as I described it earlier. It's not hard to fix, but you have to see it first to have a full understanding of what is happening.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i am doomed :/ there is an error link[^]
" An exception unknown softwore exception (.........) appeared in application in position 0x..... "
well thank you for your help :/ is there posibility to fix it?
my co-student from university called me to go to the beach so i would be back in 2-4 hours
|
|
|
|
|
well i did put a breakpointer as you said results are
line = {"yes i said yes, yes yes "}
str2 = {"yes"}
|
|
|
|
|
So what were the results of stepping through the code?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
the same wrong results :/
but i changed compare code (removed isalpha() ) and i created 2 Array [26] with A-Z and a-z and now it works perfectly just finished
Thank you for intersting !
|
|
|
|
|
Immunity18 wrote: the same wrong results :/
Which doesn't tell much.
Immunity18 wrote: ...i created 2 Array [26] with A-Z and a-z and now it works perfectly
So what exactly was this portion of your code doing? Are you for sure that using the two arrays instead of isalpha() is just not masking an underlying problem?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
well my opinion is what is working you dont touch it ! :P (greek phrase )
well when i end the project i think i will try to understand why that doesnt work
|
|
|
|
|
Immunity18 wrote: well my opinion is what is working...
That's my point. You have not actually verified whether it is working or not. Simply looking at the output as proof of whether a section of code works or not is just asking for trouble.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
about the debug yes its debug arrestion (how it is spelled:P)
my code is
int CInfoRecoverDlg::Compare( CString line , CString str2)
{
int nCount = 0;
int index=0;
for (int i = 0 ; i < line.GetLength() ; i++)
{
index=line.Find(str2,index);
if( index!= -1 )
{
if( !isalpha(line.GetAt(index-1)) && !isalpha(line.GetAt(index+ str2.GetLength())))
{
nCount++;
index++;
}
}
else
return nCount;
}
return nCount ;
}
Well yes i just want to complete the project (so i can give it ) and then i try to fingure out (my University teacher dont want to see C code correction but a program that work like google machine (give some words and return 10 top files.txt in chance to be what you want )
He asked us to make it in Visual Basic but as he teach us the Basic i felt i would confuse even more the C/C++ so i decide to make it in C/C++
|
|
|
|
|
hello
how can i read a stream from the sound card?
|
|
|
|
|
A couple popular ways are:
Windows Multimedia Waveform Audio[^]
DirectSound[^]
There's no performance advantage using DirectX (DirectSound) over windows multimedia for audio.
If you've done any DirectX coding, or already use DirectX in your code, then you may find
DirectSound easier.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Search CodeProject for "audio".
If you are doing this at a Windows multimedia level (not DirectX), search for WaveIn. There are a few projects to start you on the way.
|
|
|
|
|
Hello,
I want to call a function in the application class from the CMainframe class.
Is it possible since CMainframe is created in the InitInstance() function of the application class.
And in general what is the relation between a CMainframe and the application class.
Prithaa
|
|
|
|
|
prithaa wrote: Is it possible...
Yes.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
To expand on DavidCrow's excellent reply...
prithaa wrote: in general what is the relation between a CMainframe and the application class.
They are both in the same application(?). It's up to you to provide the relationship if you need
it. Typically, the CWinThread::m_pMainWnd is set to point to your app's main window. If this
is done then the application will terminate when the main window closes.
Also, the application class is typically the thread that provides the message loop which
dispatches messages to the main window.
Unless you've passed a pointer/reference to your app class to the main window class (in which
case you could use that to call a method of the app class) then you can use AfxGetApp() to get
a pointer to the one and only app class object, something like:
CMyWinApp *pMyWinApp = DYNAMIC_DOWNCAST(CMyWinApp, AfxGetApp());
pMyWinApp->MyAppMethod(...);
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
it is possible to use:
To access the main frame:
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
To access the CWinApp derived:
extern CMyApp theApp;
This "theApp" is usually declared in the CMyApp.cpp by default if you use assistant in VC++
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
I'm currently trying to get our code to link using VS8 or 2005. We are currently using VS7 or 2003.
When I link I get a collection of the following messages.
LIBCMT.lib(printf.obj) : error LNK2005: _printf already defined in libredir.obw
LIBCMT.lib(calloc.obj) : error LNK2005: _calloc already defined in liballoc.obw
LIBCMT.lib(realloc.obj) : error LNK2005: _realloc already defined in liballoc.obw
LIBCMT.lib(vprintf.obj) : error LNK2005: _vprintf already defined in libredir.obw
After these errors obviously the linking fails.
The code I am linking is a collection of C and C++ code producing DLLs and EXEs. Bits of the system were written in the very early days of windows. So there we have our own code to do malloc, calloc, printf, etc.
What I understand after spending hours reading Microsoft and this site is that prior to VS8 we were linking using the single threaded library libc.lib. Now this is no more and thus we have to use the multi-threaded libcmt.lib. This is the cause of the bother.
The questions Now we are being forced to use the multi-threaded library libcmt.lib how do I stop it complaining about our own defined functions and let our software compile?
The answer isn't obviously to get rid of our versions because our huge code base uses these functions instead of microsoft and in the case of printf does something special to the output.
One oddity is that we have defined our own malloc and it doesn't whinge about that.
Any help would be gratefully received.
steven
-- modified at 13:00 Thursday 24th May, 2007
|
|
|
|
|
Hi,
My application crashes when i do a Drag and Drop on the Browse window, it does not happen often. I happens only when we do a improper drag and drop, meaning if the selection is not made and still we manage to Drag. Windows thinks that there is an object attached to Drag but has a null pointer and crashes in the
DataSource.DoDragDrop(m_dropEffectAllowed)
function,
void OnBegindrag(NMHDR* /*pNMHDR*/, LRESULT* pResult)
{
//NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;
// If no drop effects are allowed then just exit.
if (0 == m_dropEffectAllowed) return;
// Create an item list for all of the selected objects.
CPyrItemList* ppil = CreateSelectedItemList (m_fIgnoreClassFoldersInLists);
if (NULL == ppil) return;
// If we drag the data to another process and it takes a long time
// to complete the drop, it's possible for us to get "server busy"
// dialogs while we're waiting for the other process. So we want
// to turn off those dialogs now.
// Create a data source to do the drag-drop and then do the
// drag-drop.
CPyrItemListDataSource DataSource;
DataSource.Create (*ppil);
/*DROPEFFECT dropEffect = */ DataSource.DoDragDrop (m_dropEffectAllowed);
delete ppil;
}
Can someone pls suggest?
|
|
|
|