how can i append text or concatenate text in a const char *???
in this function, if i put "A Journey to the Center of the Earth", it will return "Jules Verne", but i want "Jules Verne" inside brackets, like "[Jules Verne]", i was thinking if its possible to concatenate two brackets.
I have tried strcpy and sprintf.
Appending to a char* means that the location to where that char* points to has some free space. String literals have none. Also, the const in const char* means that whatever it points to cannot be tampered with.
What you could do is make a copy of the string and do whatever you like with it, however this would require dynamic allocation (should I explain why?) and if you did that, you'd forget to delete it, resulting in a memory leak.
If you can, use std::string. It would make the task trivial.
If you can't, you should change the function to void author_req(const char* book, char* result) so that the caller gets to decide how he wants to allocate memory.