How to concatenate strings in C, not like 1
+ 1
= 2
but like 1
+ 1
= 11
.
I think you need string concatenation:
#include <stdio.h>
#include <string.h>
int main() {
char str1[50] = "Hello ";
char str2[] = "World";
strcat(str1, str2);
printf("str1: %s\n", str1);
return 0;
}
from: http://irc.essex.ac.uk/www.iota-six.co.uk/c/g6_strcat_strncat.asp
To concatenate more than two strings, you can use sprintf, e.g.
char buffer[101];
sprintf(buffer, "%s%s%s%s", "this", " is", " my", " story");
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