'\0' and editbox glitch!

Started by
9 comments, last by GekkoCube 22 years, 1 month ago
If ''\n'' is windows version for carriage-return + line-feed. Then the windows equivalent for ''\0'' is what? Second, I have this editbox in my MFC app - a really big editbox so the user can types a story in there if he/she wanted to. The problem is that if I type a bunch of words (maybe approx 50 or so) the cursor gets sent back to the top...AND when I type, it display the text backwards! If i typed hello (after the cursor gets set back to the top) it will display "olleh" Any idea what this glitch could be? I noticed that turning off UpdateData(TRUE) and UpdateData(FALSE) doesnt cause the problem to occur. ~ I am a DirectX to OpenGL convert! ~
Advertisement
quote:Original post by GekkoCube
If ''\n'' is windows version for carriage-return + line-feed.
Then the windows equivalent for ''\0'' is what?

Second,
I have this editbox in my MFC app - a really big editbox so the user can types a story in there if he/she wanted to.
The problem is that if I type a bunch of words (maybe approx 50 or so) the cursor gets sent back to the top...AND when I type, it display the text backwards!

If i typed hello (after the cursor gets set back to the top) it will display "olleh"

Any idea what this glitch could be?
I noticed that turning off UpdateData(TRUE) and UpdateData(FALSE) doesnt cause the problem to occur.



~ I am a DirectX to OpenGL convert! ~


\r\n for edit box line return

quote:Original post by GekkoCube
If ''\n'' is windows version for carriage-return + line-feed.

Actually, it''s "\n\r."

quote:Then the windows equivalent for ''\0'' is what?

Where ''\0'' is supposed to be what exactly?

As for your other question, I have no information at this time. Maybe later, or maybe someone else.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
''\0'' is at the end of a string...
im guessing this is the problem....because i get this weird character, looks like a ''y'' with a '':'' turned 90 degrees on top.


~ I am a DirectX to OpenGL convert! ~
Ya the ''Y'' with a '':'' means you didn''t terminate the string... are you using CString or LPCSTR?
PaladinGLT
No matter what the system, \n is always "line feed" and \r is always "carriage return" (the "r" is for "return"). Now, Windows requires both to send the cursor to the beginning of the next line. Most other systems only need \n. Of course, those last two sentences only apply to the respective systems' APIs, not the C/C++ standard libraries.

Actually, I believe it's \r\n—I've always done it that way and it's always worked.

There are no platform-specific equivalents for \0. The \0 escape sequence signifies the terminator for the string. Since C-style strings are just arrays of characters, that's how most Windows API functions (and all C library functions), which use C-style strings, know where a string ends. You rarely have to deal with the terminator explicitly, unless you're doing some custom string manipulation that isn't handled by the C library. But even if you do, it's \0 on all platforms because it's part of the language.

[edited by - merlin9x9 on March 18, 2002 12:13:26 AM]
\n\r

0xa/0xd

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
Apparently, both \r\n and \n\r work (at least with MessageBox). I just tested it. But the conventional way to do it is carriage return, line feed; this is /r/n.
"/0" stands fore Null Terminator
Z
Message box works fine with just \n so it doesn''t really work to test it there... do this.

char CrLf[2] = {0x0d, 0x0a};
MyTextBox.SetWindowText(CString("First Line") + CrLf + "SecondLine");
PaladinGLT

This topic is closed to new replies.

Advertisement