I want to add "" to {"status":true} so that the string looks like "{"status":"true"}". How can I insert characters to a string at specific locations?
I tried strncat(), but wasn’t able to get the desired result. I read that you need to create your own function for that. Can anyone show me an example?
Yes, you will need to write your own function for that.
Note that a string in C is a
char[], i.e. an array of characters, and is of fixed size.What you can do is, create a new string that serves as the result, copy the first part of the subject string into it, append the string that goes in the middle, and append the second half of the subject string.
The code goes something like,
Working example here