Displaying data in edit control

I am using recv() to receive data represent characters from a socket. The problem I am facing is how to display this data in Edit control. When I display the received data just for checking using AfxMessageBox function, I get the received text with garbage character appended to the text. I think the problem is with the way of displaying. Any suggestion please
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:

No, I dont think, it is the prob with the way of displaying. The text may be containing some junk values. U may have to trim it up before displaying it.
Just debug and see what character r u getting.

Try it out.
Are you interfacing with some type of Gateway that is rapping an envelope around the received socket data? Normally the control characters in the envelope is Non displayable binary datacharacters? Your edit control does not know what to do with the control characters that it is receiving.

AFXMessageBox uses a CString as it's buffer to store data, so it will store up to, but not including a Null value of whatever you give it.

An edit control is expecting only displayable ascii values along with TABS and a few other exceptable values. The edit control has it's own set of control characters and delimiters that are used to control how the data is displayed to the user. You will have to filter out all control/binary characters prior to populating your edit control with the received data.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.