append to string c without strcat code example
Example 1: program to concatenate two strings in c
#include <stdio.h>
#include <string.h>
void concatenate(char *str1, char *str2)
{
int i = strlen(str1), j = 0;
while (str2[j] != '\0')
{
str1[i] = str2[j];
i++;
j++;
}
str1[i] = '\0';
}
int main()
{
char string1[20], string2[20];
gets(string1);
gets(string2);
concatenate(string1, string2);
printf("String 1 : ");
puts(string1);
return 0;
}
Example 2: how to concatenate two big strings without using strcat in c++
cin >> doubleNumber;
cin.ignore();
getline(cin, stringName);