1char str[80];
2strcpy(str, "these ");
3strcat(str, "strings ");
4strcat(str, "are ");
5strcat(str, "concatenated.");
1#include <stdio.h>
2#include <string.h>
3int main()
4{
5 char a[1000], b[1000];
6
7 printf("Enter the first string\n");
8 gets(a);
9
10 printf("Enter the second string\n");
11 gets(b);
12
13 strcat(a, b);
14
15 printf("String obtained on concatenation: %s\n", a);
16
17 return 0;
18}
1#include <stdio.h>
2#include <string.h>
3int main() {
4 char str[80];
5strcpy(str, "these ");
6strcat(str, "strings ");
7strcat(str, "are ");
8strcat(str, "concatenated.");
9printf("%s\n", str);
10}
1// this program is to contenate strings without using string function
2
3#include <stdio.h>
4#include <string.h>
5
6void concatenate(char *str1, char *str2)
7{
8 int i = strlen(str1), j = 0;
9
10 while (str2[j] != '\0')
11 {
12 str1[i] = str2[j];
13 i++;
14 j++;
15 }
16
17 str1[i] = '\0'; // declaring the end of the string
18}
19
20int main()
21{
22 char string1[20], string2[20];
23 gets(string1);
24 gets(string2);
25
26 concatenate(string1, string2);
27
28 printf("String 1 : ");
29 puts(string1);
30
31 return 0;
32}
1- (NSString *)strCat: (NSString *)one: (NSString *)two
2{
3 NSString *myString;
4 myString = [NSString stringWithFormat:@"%@%@", one , two];
5 return myString;
6}
7