|
Immunity18 wrote: ...things dont go well
Which means what? Have you stepped through Compare() to find out what is wrong?
"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 mean i have the same phrase in the file and in CString so it had to be the same result ?
when i try to debug it says "one or more breakpoints cant ..." and it show me a Kernel thing
|
|
|
|
|
Immunity18 wrote: i mean i have the same phrase in the file and in CString so it had to be the same result ?
Just because you pass a particular value to a method does not mean that same value is being "seen" by the method correctly. Set a breakpoint within the method and examine the values.
Immunity18 wrote: when i try to debug it says "one or more breakpoints cant ..." and it show me a Kernel thing
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...
"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
|
|
|
|
|
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
|
|
|
|