Reputation: 319
I have a function that requires to send a string with <cr>
at the end. How can I directly
join the string-part with the <cr>
= 0x0D in C without using any library function? (I am using uC.)
Example array/string "ABC\x0D", but 0x0D should be not sent as ascii but as <cr>
.
Upvotes: 0
Views: 1064
Reputation: 148975
Provided you have enough room in your array, you simply put at the end of the string a 0x0d
and a \0
. Example :
char str[8] = "ABCDEF";
This string contains 6 characters and the terminating null : it can accept the cr. How to do that :
str[6] = '\r'; /* or 0x0d or 13 */
str[7] = '\0'; /* or 0x0 or 0 */
That's all...
Upvotes: 2