| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | I`m confused about a sni |
DD> > strcpy(cTest, "12345678901") ; > WinMessageBox(/*...*/ cTest /*...*/) ; > > No matter what I do it ALWAYS displays the first 3 chars and truncates > the rest. DD> If it is *truly* the case that there is no intervening code between these two lines, then even heap corruption isn't the answer (unless your application is multithreaded), because there is no heap mauipulation between the time that the memory pointed to by `cTest' is modified, and the time that it is passed to WinMessageBox(). I suspect that you are a victim of corrupt string literals. It may well be that at some point you are writing over the memory that contains the string literal "12345678901" at some other point in your program, most likely by exceeding the bounds of an array that has static storage duration (i.e. that resides in the "data segment" rather than on the stack or the heap), or by aliasing a literal to a pointer and then modifying the data pointed to. One way to check this is to use one of the little-used features of many C++ compilers : that of forcing string literals to be grouped into a read-only data area. This will cause the program to be halted by OS/2 as soon as something attempts to overwrite those literals. Most of the C++ compilers for OS/2 support this in one way or another. With MetaWare High C++, for example, you surround the strcpy line by `pragma On(Read_Only_Strings);' and `pragma Pop(Read_Only_Strings);'. Of course, if the problem *is* that you are overrunning an array with static storage duration, rather than pointer aliasing, then moving the strings into a read-only area simply means that something else will be overwritten instead, in which case it is time to fire up the debugger. > JdeBP < ___ X MegaMail 2.10 #0: --- Maximus/2 3.00* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4) SEEN-BY: 270/101 620/243 711/401 409 410 413 430 808 809 934 955 712/407 515 SEEN-BY: 712/517 628 713/888 800/1 7877/2809 @PATH: 440/4 141/209 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.