How can I prepend char c to char* myChar? I have c has a value of "A", and myChar has a value of "LL". How can I prepend c to myChar to make "ALL"?
How can I prepend char c to char* myChar ? I have c has
Share
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.
This should work:
Just remember to
free()the resulting new string when you are done using it, or else you will have a memory leak.Also, if you are going to be doing this hundreds or thousands of times to the same string, then there are other ways you can do it that will be much more efficient.