Built a based on the MFC dialog, added two edit box, in the first edit box to ABC \ 0 ABC, then future generations, in the second dialog after the paste, the result is still the ABC \ 0 ABC;
But if I write a function to realize the function, the first frame of the string is assigned to the second dialog, the result is ABC, namely the \ 0 for a terminator, string truncation!
Want to consult everybody a great god, and how to do copy and paste of the system is not lost \ 0 at the back of the string? Or you great god have what good method? (will appear in the data treatment of recent \ 0, often behind the data, so the thought of the system of copy and paste, want to know is how to achieve! There is no find the right information online! Grateful!
CodePudding user response:
\ said characters with individual saying \ '\ \' heart
\ \ "" 0" so as not to have problems
CodePudding user response:
reference 1st floor zgl7903 response: \ said characters with individual saying \ '\ \' heart \ \ "" 0" so there will be no problem That is to say, I need to handle the string to copy, paste and then put the string in the opposite way? CodePudding user response:
refer to the second floor weixin_44690344 response: Quote: refer to 1st floor zgl7903 response: \ said characters with individual saying \ '\ \' heart \ \ "" 0" so there will be no problem That is to say, I need to handle the string to copy, paste and then put the string in the opposite way? Turn \ said ideogram is done in the compile phase, Cstrings szSrc=https://bbs.csdn.net/topics/_T (ABC \ \ "" 01234"); SetDlgItemText (IDC_EDIT1 szSrc); Cstrings szStr2; GetDlgItemText (IDC_EDIT1 szStr2); SetDlgItemText (IDC_EDIT2 szStr2); CodePudding user response:
reference 1st floor zgl7903 response: \ said characters with individual saying \ '\ \' heart \ \ "" 0" so there will be no problem \ \ in ASCII compile-time as a whole, ASCII is 5 c, which I understand, thank you very much! Also would like to ask you! Copy of the string is written casually, don't know the length of the string and the content in advance, and then I should with what method to the string of \ \ \ 0 0 changed? (use a string function replacement treatment, encounter \ 0 is over, read is incomplete; With characters one by one and don't know what can copy the length of the string, strlen is not the right length, because when encounter \ 0 think over!) Thank you so much! CodePudding user response:
reference 1st floor zgl7903 response: \ said characters with individual saying \ '\ \' heart \ \ "" 0" so there will be no problem When I was doing the socket, the problem of server perform two send function to send information to the client, the client only perform a recv, because the server sends the data center will automatically add \ 0 twice, cause the client recv data server for the first time send, is the second time the send data is lost, for memory found two of the data to the client, how can place to put the two are recv the send data to a string, in the middle of the two data with Spaces or line breaks and distinguish! CodePudding user response:
'\ 0' is a string terminator 0 So you can use the received data as string processing line, like cstrings MFC do + operation CodePudding user response:
refer to 6th floor zgl7903 response: '\ 0' is a string terminator 0 So you can use the received data as string processing line, like MFC cstrings do + operation can Server performs the following two consecutive send function Send (sockConn sendtext1, strlen (sendtext1) + 1, 0). //sendtext1 as "ABC" Send (sockConn sendtext2, strlen (sendtext2) + 1, 0). //sendtext2 for "efg "Client to perform again the recv function, to save the received data as recvtext, for memory found recvtext received data for ABC \ 0 efg \ "0", (the data is right), but for the data application, such as putting recvtext assigned to other variables, the results for "ABC", like you said, recvtext think they only "ABC", meet \ 0 think her string has ended, but actually there "efg", read "efg" how so? CodePudding user response:
The strlen (sendtext2) + 1 '\ 0' namely; Change the separator CodePudding user response:
//it is assumed that has received the complete data, without considering the data truncated Char * pStr=pRecv (char *);//points to receive buffer Int iTotalLen=0; The total length// CStringArray rcvStr;//receiving array While (iTotalLen & lt; IRecvedLen) { RcvStr. Add (cstrings (pStr));//added to the array Int iLen=(int) strlen (pStr) + 1;//end of the string length + operator PStr +=iLen;//move to the next set of data starting position ITotalLen +=iLen;//the length of the total processing } CodePudding user response:
refer to the eighth floor schlafenhamster response: strlen (sendtext2) + 1 '\ 0' namely; Change the separator Have a try later, thank you!