|
Now my app is just flooding with user breakpoints everywhere. I've checked if i'm freeing some memory that's already freed but no. And most of the time the user breakpoint comes when i'm in an API function so i can't debug inside the function.
Thanks
|
|
|
|
|
You are observing a symptom of some other problem. Probably you are passing bad data into an API function. Work your way back up the call stack 'till it's in your own code, and check for things like de-allocated memory being used, or bogus pointers.
Shog9
------
If you really what to get shitfacde tell a crowded bar that is is yourt borthday and hife your wallet. you ka will many more friends.
- David Wulff, Brithday selebrations, 9/19/02
|
|
|
|
|
if you allocate memory, then write something to it plus 1 byte or more. You could have a "user breakpoint" when you'll free the memory block.
|
|
|
|
|
Hi
I use odbc-access driver in c++ and have a crecordset, created with the adress of a database. I can use my CRecordset-pointer m_pRS to navigate through the set, but whenever i want to edit, update, add or delete something from the recordset (like m_pRS->Edit(); ) i get a debug assertion failure (visual c++ 6.00)
Here is the initializing code for the recordset:
<br />
CRecordset *rs = new CRecordset(&m_DB);<br />
m_pRS = rs;<br />
m_hStmt = m_pRS->m_hstmt;;<br />
<br />
SDWORD b1;<br />
SDWORD b2;<br />
<br />
SQLBindCol (m_hStmt, 1, SQL_C_CHAR, (PTR)m_mAkt.m_sName, sizeof(m_mAkt.m_sName), &b1);<br />
SQLBindCol (m_hStmt, 2, SQL_C_DOUBLE, (PTR)&m_mAkt.m_fDichte, sizeof(m_mAkt.m_fDichte), &b2);<br />
SQLBindCol (m_hStmt, 3, SQL_C_CHAR, (PTR)m_mAkt.m_sBeschreibung, sizeof(m_mAkt.m_sBeschreibung), &b1);<br />
<br />
<br />
try<br />
{<br />
m_pRS->Open( CRecordset::snapshot, <br />
_T("SELECT * FROM Material ORDER BY Materialname, Dichte"),<br />
CRecordset::none);<br />
<br />
GetMaterialNum();<br />
}<br />
catch ( CDBException *pDBE)<br />
{<br />
AfxMessageBox("Database Fehler: "+pDBE->m_strError); <br />
return false;<br />
} <br />
<br />
Can someone help me why navigating (calling for example m_pRS.MoveNext(); )works, but not .Edit() , .Update(), .AddNew and so on?
Thank you
niklas
|
|
|
|
|
How do I place a hypertext link in my about dialog in mfc ?
Thanks!
|
|
|
|
|
|
Uwe Keim wrote:
http://codeproject.com/miscctrl/hyperlink.asp[^]
what do you think about the comments from "AnthonyJ" about:
"open" with new IE window?
Is the described code a portable (running Win9x-XP) to open a URL in a new window? I haven't searched Google yet, but I'm curious.
|
|
|
|
|
Hello there,
I'm sure all of you read some articles about C++ .NET !
And when i always ask you about it, you say: "Everything is improved in C++ .NET, MFC and ATL and etc is improved."
But now, i want to know Did you switch on it ?
Do you use C++ .NET instead of VC++ 6.0 ?
What's your programming language, right now ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hadi_Rezaie wrote:
But now, i want to know Did you switch on it ?
Do you use C++ .NET instead of VC++ 6.0 ?
What's your programming language, right now ?
No, no and (the VC6 supported subset of) C++.
|
|
|
|
|
I'm still using VC++ 6.0 for my commerical work. I've just got too much time and code invested to change over yet.
I'm playing with VC7 and C# but haven't used them to make money yet. I'll have a look at the Everett release to see if it is worth the time and money to swap to VC7.
Michael
Programming is great. First they pay you to introduce bugs into software. Then they pay you to remove them again.
|
|
|
|
|
Hi guys,
I've problem reading a binary file, however it's successful in reading non-binary files such as text/wri files.
Specifically, the buffer reads NULL bytes and gives me ASSERT(lpBuf != NULL) from filecore.cpp, line 243. But, why is this just happening for binary files and not for the non-binary ones? I'ev tried the c runtime function fread() and it fails on the 2nd attempt of the loop yielding some 9 odd bytes even when reading large files (400kb).
This is the code:
CFile pFile (sFilename, CFile::modeRead);
int iReadSize = 0;
while(true){
iReadSize = pFile.Read(pBuf, 4096);
if(iReadSize == 0)
break;
else{
//my processing goes here
}
}
pFile.Close();
Any suggestions please?
Thank you.
|
|
|
|
|
That code looks ok except for pBuf. The ASSERT(lpBuf != NULL) indicates that you aren't initializing pBuf. Can you post the rest of the code?
Todd Smith
|
|
|
|
|
Hi Todd;
void MyClass::Read(CString sFilename)
{
BYTE *pBuf = new BYTE[4096];
CFile pFile (sFilename, CFile::modeRead);
int iReadSize = 0;
while(true){
iReadSize = pFile.Read(pBuf, 4096);
if(iReadSize == 0)
break;
else{
//my processing goes here
}
}
pFile.Close();
}
This is all there's to it. But, it works only successfully to .TXT/WRI files and not the binary. I am very parnoid about the BYTE buffer. You think the buffer being a BYTE has anything to do with it? I've tried all versions of read out there... <_read(...) and fread(...)>, and I've also tried the CHAR buffer instead for the BYTE buffer.
Let me know please.. thanks.
Jey
|
|
|
|
|
First off you should probably change that to
if (iReadSize <= 0)
break;
Don't forget to call delete on pBuf when you're done
delete [] pBuf;
You might try adding the share flag
CFile pFile(sFilename, CFile::modeRead | CFile::shareDenyWrite);
If you're getting ASSERT(lpBuf != NULL) then that means that you're doing something to pBuf in your processing stage. If you step through your code you might see that the first Read is successful and that the second Read is where your code is failing because pBuf is now 0.
BYTE is fine. It's the same as
char* pBuf = new char[4096];
Todd Smith
|
|
|
|
|
There are two types of class declarations in managed c++. __gc and __value.. i understand the difference between the two and I do not need a detailed explanation of either, but am unsure of when __value should be used. They say that __value is more efficient because it doesn't go on the clr (common language runtime heap) and doesn't have to dereferenced. In support of the __gc declaration, all objects are pointers to memory locations and must be dereferenced. The advantage of using __gc is that it uses visual c++.net's ability to garbage collect when the object goes out of scope. Am i correct in saying that the __value type does not take advantage of this feature? Also, in the opinion of managed c++ developers, would you all say that it is in the spirit of visual c++.net to use the reference type (__gc) over the value type (__value)? or have the experienced developers in this forum found uses for both in the .net world? Thanks!
~a confused developer
xai
|
|
|
|
|
Hi,
In a dialog box I am having two sets of radio buttons, in separate group boxes, but then they are all behaving the same...How do I make them behave separately.
I am a beginer and this is a big doubt for me. Pls help
Arthi
|
|
|
|
|
In resource editor set Group flag to first radio button in each group (make sure that they are in in good order in tab order)
Pavel
Sonork 100.15206
|
|
|
|
|
You need to set up group flags. You can do this programatically or if your using the resource editor you can set it in the properties. Just set the first radio button in each set of two with a WS_GROUP attribute.
Regards,
Brian Dela
|
|
|
|
|
Hi!
currently I'm programming an app that sends packets to (game)servers. Some packets look like this:
"\x12\x02trb2" , which means that they contain hexadecimal values.
If I define them in my program like this:
LPCTSTR PACKETS[NUMPACKETS] =
{
(...)
"\x12\x02trb2"
};
they get sent correctly. But I want my program to be more dynamic and let the user specify own packets that he wants to send to a server.
Of course, when the user types "\x12\x02trb2" into an edit box the packet will not be sent hexadecimal but as a complete string.
So I tried to replace the most important escape sequences in the edit box like this:
string.Replace("\\0", "\0");
string.Replace("\\t", "\t");
string.Replace("\\x", "\x");
string.Replace("\\n", "\n");
string.Replace("\\r", "\r");
All lines conpile fine, except the 3rd one. The compiler error is (translated from german):
error C2153: Hexadecimal constants need to contain at least one hexadecimal number
Does anybody know how I can get this to work?
thanks in advance
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
\x means nothing, \x12 is a character encoded with 12. You need to replace "\\x12" with '\x12'.
Pavel
Sonork 100.15206
|
|
|
|
|
thanks...how many numbers may follow after \x?
I will write my own parsing routine then
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Two. I'm not sure how's with it in UNICODE strings, but if I remeber it good, it's done using two following \x with two digits.
Pavel
Sonork 100.15206
|
|
|
|
|
Currently I'm writing a parser, but I have one problem:
if(d1 != -1 && d2 != -1)
{
numbers.Format("%i%i",d1,d2);
replacechar.Format("\\x%i%i",d1,d2);
CString digits = string.Mid(findx+2,2);
int iDigits = atoi(digits);
newchar.Format("%x",iDigits);
string.Replace(replacechar, newchar);
}
replacechar is \x12 , this is correct.
But now I need to convert it to hexadecimal:
iDigits is 12 , this is correct as well.
But newchar.Format("%x",iDigits); doesn't convert it correct into hexadecimal, since I don't get any answer from the server.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You are treating the hex number like a decimal one in atoi.
You need to convert it to decimal instead - then you get the needed character code.
Pavel
Sonork 100.15206
|
|
|
|
|
Could you tell me how to do it? I've never done it before
thanks
modified 12-Sep-18 21:01pm.
|
|
|
|