Answers for "c concatenate string"

C
12

c concatenate strings

char str[80];
strcpy(str, "these ");
strcat(str, "strings ");
strcat(str, "are ");
strcat(str, "concatenated.");
Posted by: Guest on March-22-2020
2

how to combine strings in c

#include <stdio.h>
#include <string.h>
int main() {
	char str[80];
strcpy(str, "these ");
strcat(str, "strings ");
strcat(str, "are ");
strcat(str, "concatenated.");
printf("%s\n", str);
}
Posted by: Guest on February-06-2021
1

program to concatenate two strings in c

// this program is to contenate strings without using string function

#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';  // declaring the end of the string
}

int main()
{
  char string1[20], string2[20];
  gets(string1);
  gets(string2);
  
  concatenate(string1, string2);
  
  printf("String 1 : ");
  puts(string1);
  
  return 0;
}
Posted by: Guest on August-28-2020
0

c concatenate and allocate string

// null protected
char* strconcat(char *str1, const char *str2)
{
	char *str = NULL;
    size_t len1 = 0;
    size_t len2 = 0;

	if (str1)
    	len1 = strlen(str1);
    if (str2)
    	len2 = strlen(str2);
    if (!(str = calloc(sizeof(char), (len1 + len2 + 1))))
        return NULL;
    if (str1)
        memcpy(str, str1, len1);
    if (str2)
        memcpy(str + len1, str2, len2);
    return (str);
}
Posted by: Guest on January-11-2021
1

objective c strings concatenate

- (NSString *)strCat: (NSString *)one: (NSString *)two
{
    NSString *myString;
    myString = [NSString stringWithFormat:@"%@%@", one , two];
    return myString;
}
Posted by: Guest on December-04-2020

Code answers related to "C"

Browse Popular Code Answers by Language