How can I combine two const char*s into a third?
i'm trying to do this with this code:
const char* pName = "Foo"
printf("\nMy name is %s.\n\n\n",pName);
const char* nName;
int num_chars = asprintf(&nName, "%s%s", "Somebody known as ", pName);
But I get this error:
'asprintf': identifier not found
I include stdio.h via this code:
#include <stdio.h>
Simple, just use C++:
const char* pName = "Foo"
std::string name("Somebody known as ");
name += pName;
const char* nName = name.c_str();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With