开发者

How to add a null terminator in string?

say i have a loop i want to add the first value "this" by the command开发者_运维百科

strcat(l->value,l->db.param_value.val);

now i want to append a null and move it one more space to the right so i can have

"this"'\0'"is"'\0' 

if i do strcat continuously in a loop it just gives me "thisis", anyone have a suggestion on how to do this ?

Ive tried the statement below it didn't work

      l->value=  l->value[1 + strlen(l->db.param_value.val)];

Thank you!


Try

l->value += strlen(l->db.param_value.val) + 1;

Assigning l->value[1 + strlen(l->db.param_value.val)] essentially means treating the small value of a character as an address. Which is most definitely not what you want.

Also, make sure there is enough space and all that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜