I need to put “hello world” in c.
How can I do this ?
string a = "hello ";
const char *b = "world";
const char *C;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
or without modifying
a:Little edit, to match amount of information given by 111111.
When you already have
strings (orconst char *s, but I recommend casting the latter to the former), you can just “sum” them up to form longer string. But, if you want to append something more than just string you already have, you can usestringstreamand it’soperator<<, which works exactly ascout‘s one, but doesn’t print the text to standard output (i.e. console), but to it’s internal buffer and you can use it’s.str()method to getstd::stringfrom it.std::string::c_str()function returns pointer toconst charbuffer (i.e.const char *) of string contained within it, that is null-terminated. You can then use it as any otherconst char *variable.