I'm currently using
char *thisvar = "stringcontenthere";
to declare a string in C.
Is this the best way to declare a string in C?
And how about generating a C-String from C++-Strings?
In C it depends on how you'll use the string:
char* str = "string"; method is ok (but should be char const*)char str[] = "string";
char* str = strdup("string");, and make sure it gets freed eventually.if this doesnt cover it, try adding more detail to your answer.
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