0

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!

2
  • Is l->value an array or a pointer to a buffer? Do you want l->value to track the location where the next string will/should be placed? Do you have something else keeping track of the start of the buffer, or should l->value be left alone and a different temporary pointer keep track of where the next string should go? And do you have something that indicates how big the target buffer is (so you can detect and avoid overflowing it)? Commented Aug 9, 2011 at 19:33
  • It's not clear what you want. It sounds like you want null terminators in the middle of your string, which is probably a very bad idea, unless you really know what you're doing. Commented Aug 9, 2011 at 19:45

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.