If the input is being treated like a string, then room is needed to apply the null-termination (a '\\0'
) at the end. That is if the data is 'a'
, then the string representation ( "a"
) is stored in memory as two characters 'a'
and '\\0'
. The '\\0'
is needed to tell the usual string processing suspects where the string ends.
Without knowing anything about the tools you're using I can't say for sure, but you might be able to assign to a character variable (as opposed to a character array variable).
Looking briefly at the docs along the link you posted, I suspect that you should be using std::string
as the receiving type for textual data.
可能您需要在字符串末尾的空字符空间?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.