Possible Duplicate:
concatenate char array in C
How to concatenate:
char *a="abcd";
char *b="1234";
using the strcat()? And answer to the same when user enters *a and *b?
EDIT missed out this: without using another array.
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.
You can’t monkey around with the string literals you’ve already initialized – they’re sitting somewhere in memory & can’t/shouldn’t be rewritten.
If you don’t want another statically-defined array but don’t mind dynamic allocation, the code below may accomplish what you’re looking for:
If that’s still unacceptable, consider a different approach to initializing your string literals.