Home > Back-end >  An array is assigned to a string
An array is assigned to a string

Time:03-16

Want the content of Real array of all assigned to a string, finally want to achieve the results as follows: sfvalue="https://bbs.csdn.net/topics/F2F10B000001F3F1F3F2F3F30102471E" (that is to achieve a string of hexadecimal message into hexadecimal string, not sure if this description is correct), use the following code, can appear the following questions, which is encountered in the process of assigning 0 (0 x00), the end of the string is considered to be '\ 0', finally the result is sfvalue="https://bbs.csdn.net/topics/F2F10B", 0 at the back of the all have no, the problem is there a solution? A great god taught for all of you!

 
Char Real [128]={x0b xf2 0, 0 xf1, 0, 0 x00 to 0 x00 to 0 x01, 0 xf3, 0 xf1, 0 xf3, 0 xf2, 0 xf3, 0 xf3, 0 x01, 0 x02, 0 x47, 0 x1e};
String sfvalue=https://bbs.csdn.net/topics/Real;

[original view]={_Myval2={_Bx={_Buf=0 x0547fb30 viper \ "v" _Ptr=0 x000bf1f2 & lt; Error while reading the string of characters, & gt; _Alias=0 x0547fb30 viper \ "v"} _Mysize=... }}

CodePudding user response:

 # include & lt; Stdio. H> 
# include & lt; iostream>
# include & lt; String>
using namespace std;
Char Real [128]={x0b xf2 0, 0 xf1, 0, 0 x00 to 0 x00 to 0 x01, 0 xf3, 0 xf1, 0 xf3, 0 xf2, 0 xf3, 0 xf3, 0 x01, 0 x02, 0 x47, 0 x1e};
Int I, L=16;
Char hexstr [260].
String sfvalue;
Int main () {
for (i=0; iHexstr [L * 2]=0;
sfvalue=https://bbs.csdn.net/topics/string (hexstr);
cout<" [" & lt; & lt; sfvalue<& lt; "] "& lt; return 0;
}
  • Related