Click here to Skip to main content
16,007,932 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CMutex Pin
Cathy1-Feb-02 20:39
Cathy1-Feb-02 20:39 
GeneralRe: CMutex Pin
Rick York1-Feb-02 21:08
mveRick York1-Feb-02 21:08 
GeneralRe: CMutex Pin
Cathy2-Feb-02 5:13
Cathy2-Feb-02 5:13 
GeneralWTF Pin
Stephen Caldwell1-Feb-02 13:02
Stephen Caldwell1-Feb-02 13:02 
GeneralRe: WTF Pin
Swinefeaster1-Feb-02 14:01
Swinefeaster1-Feb-02 14:01 
GeneralRe: WTF Pin
Sprudling1-Feb-02 14:03
Sprudling1-Feb-02 14:03 
GeneralRe: WTF Pin
Stephen Caldwell1-Feb-02 14:27
Stephen Caldwell1-Feb-02 14:27 
GeneralRe: WTF Pin
Tim Smith1-Feb-02 14:32
Tim Smith1-Feb-02 14:32 
Sprudling is close to being right.

C/C++ uses NULL terminated strings. So when you look at a character array in the debugger or printing, if the NULL isn't there, then trash at the end of the string will be displayed.

Like Sprudling said, if you want to use the read data as a C/C++ string, then you need to add an 11th byte and then terminate it. For example:

char buff [11];
char obuff [21];
int n = mysock.recv(buff,10);
buff [n] = 0;  //assuming that n>=0
strcpy (obuff,buff); 


No if you aren't using the data as real strings, then the NULL isn't at all required and the extra trash is just an annoyance caused by the debugger trying to display the data as a string.

Tim Smith
Descartes Systems Sciences, Inc.
GeneralCapturing the contents of another window... Pin
Peter Weyzen1-Feb-02 12:37
Peter Weyzen1-Feb-02 12:37 
GeneralRe: Capturing the contents of another window... Pin
Stephen Caldwell1-Feb-02 13:22
Stephen Caldwell1-Feb-02 13:22 
Generalmany functions to just one Pin
Steve L.1-Feb-02 11:34
Steve L.1-Feb-02 11:34 
GeneralRe: many functions to just one Pin
Ravi Bhavnani1-Feb-02 11:54
professionalRavi Bhavnani1-Feb-02 11:54 
GeneralExtended Stored Procedures Pin
RK_20001-Feb-02 9:27
RK_20001-Feb-02 9:27 
GeneralRe: further to my question Pin
RK_20001-Feb-02 11:44
RK_20001-Feb-02 11:44 
GeneralNew version of CButtonSSL Pin
Derek Lakin1-Feb-02 9:14
Derek Lakin1-Feb-02 9:14 
GeneralFont display problems in NT, 2000 but not in 9x Pin
Jason Hihn1-Feb-02 8:23
Jason Hihn1-Feb-02 8:23 
Generaltwo-dimansional array of strings Pin
hhh1-Feb-02 8:21
hhh1-Feb-02 8:21 
GeneralRe: two-dimansional array of strings Pin
Jason Hihn1-Feb-02 8:54
Jason Hihn1-Feb-02 8:54 
GeneralRe: two-dimansional array of strings Pin
CodeGuy1-Feb-02 9:26
CodeGuy1-Feb-02 9:26 
GeneralSpeedy Net Conection Pin
Nnamdi Onyeyiri1-Feb-02 7:21
Nnamdi Onyeyiri1-Feb-02 7:21 
GeneralRe: Speedy Net Conection Pin
Joaquín M López Muñoz1-Feb-02 7:24
Joaquín M López Muñoz1-Feb-02 7:24 
GeneralRe: Speedy Net Conection Pin
Nnamdi Onyeyiri1-Feb-02 7:42
Nnamdi Onyeyiri1-Feb-02 7:42 
GeneralNew Controls in .Net Pin
Mazdak1-Feb-02 7:05
Mazdak1-Feb-02 7:05 
GeneralRe: New Controls in .Net Pin
Christopher Lord2-Feb-02 15:18
Christopher Lord2-Feb-02 15:18 
GeneralRe: New Controls in .Net Pin
Mazdak2-Feb-02 20:44
Mazdak2-Feb-02 20:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.