Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Viewing NULL chars in Text Box???

Status
Not open for further replies.

sirbeatsalot

Programmer
Dec 7, 2001
11
US
How do i view a buffer full of binary data, which may contain char(0), in an edit box????

The edit box seems to look for the first NULL char in the buffer i am tring to display. Then it just thinks that's the end of the string i want to display. VB 6.0 allows text boxes to show NULL chars. How to do it in VC++ 6.0.

example... if my buffer contains the char(0) i wont be able to view the rest of the buffer in an edit box

char *buf="chri\0s";
SetDlgItemText(IDC_TXTOUT, buf);

displays... 'chri'

plz.. help.
 
I dont know if it is what you are searching for:
but i think that you can simply do it like this:

char *buf="chri0s";
SetDlgItemText(hwnd,IDC_TXTOUT, buf);
displays...chri0s.

or if you want do display binary numbers:
char *buf="1101100";
SetDlgItemText(hwnd,IDC_TXTOUT, buf);
displays...1101100.

 
You must replace 0-chars with another sumbols, for example with " " (You can then not see any difference between 0 ant " " in the Box ), or You must show each char in 3 bytes (as numbers 0 - 255), or You must use "\0" - there are no another ways (with RichEdit Box too).

An example:
char buf[256] ="chri\0sbadBoysaredoof\01256";
int len = 25; //25 chars
for(int i = 0; i < 25; i++) {
if( buf == 0) {
buf = ' '; //Or another char
}
}
SetDlgItemText(IDC_TXTOUT, buf);

displays... 'chri sbadBoysaredoof 1256'
Good lake
 
Thanks!! I see what you're saying. I still wonder how VB does it.

ex.

text1.text = chr(0);
msgbox(asc(text1.text)) 'Prompts &quot;0&quot;

text1.text = chr(1);
msgbox(asc(text1.text)) 'Prompts &quot;1&quot;

so some how it still stores what character it really is. Oh well, I'll use your method in c++ . thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top