I am working with the const char *
type in C. Due to the libraries I am using I am trying not to use or include other libraries (namely cstring). The function I am working in is passed a buffer of type const char *
. I want to append a finite message to the end of this buffer.
For example:
functionA (const char *buffer){
char *message = "hello world";
//code appending message to the end of buffer
//buffer now contains its original contents plus "hello world" at the end.
}
I am thinking the best approach is to create a temporary variable to take in the data from the buffer, and then add the message. Once that is done, reassign the buffer pointer to the temporary variable's reference (as I am trying to do this with the least amount of alterations to the function, to reduce the chance of a compile error).