answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

main()

{

char s1[20],s2[20];

printf("enter first string");

scanf("%s",s1);

printf("enter second string");

scanf("%s",s2);

string_concatenate(&s1,&s2);

}

count_characters(char *x)

{

int i=0, count=0;

for(i=0;*(x+i)!='\0';i++)

count++;

return count;

}

string_concatenate(char *s1,char *s2)

{

int i,j;

char s3[50];

for(i=0;i

s3[i]=s1[i];

for(j=0;j

s3[i+j]=s2[j];

s3[i+j]=s2[j];

printf("%s",s3);

getch();

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

Your homework, innit?

const char *from1= "Part1";

const char *from2= "Part2";

char *to= malloc (256);

char *q= to;

while (*q++ = *from1++);

--q;

while (*q++ = *from2++);

This answer is:
User Avatar

User Avatar

Wiki User

7y ago

Most high-level languages support concatenation of strings using the '+' operator. For example, in C++ you'd use the following:

#include<string>

std::string a = "Hello";

std::string b = "world";

std::string c = a + " " + b; // e.g., c = "Hello world"

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

import java.io.*;

class concate

{

public static void main(String args[]) throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter the string s1:");

String s1=br.readLine();

System.out.println("Enter the string s2:");

String s2=br.readLine();

String s3=s1.concat(s2);

System.out.println("The concate string is :"+s3);

}

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

String can be added to together with the plus symbol much like an int.

String a = "I like to eat";

String b = " peanut butter";

String c = a + b;

'c' will now equal "I like to eat peanut butter"

You could also use a + " peanut butter"; and not bother having a three strings

Here's one more example:

String a = "I like to eat";

a += " cheese,";

a += " bacon,";

a += " and jelly beans.";

String a will now equal "I like to eat cheese, bacon, and jelly beans." Afterwards if you use System.out.println(a);it will print that full sentence on screen.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

In C and C++, to concatenate two strings without using library functions...

char* mystrcat (char* dest, char* src) {

char* savedest = dest;

while (*dest++ != '\0);

dest--;

while ((*dest++ = *src++) != '\0);

return savedest;

}

Note: Just like the library function, this routine does not verify that there is adequate space at dest - that is your responsibility.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

You can use functions like strcat or sprintf, or do it manually:

q= to;

p= from1-1;

while (*++p) *q++= *p;

p= from2-1;

while (*++p) *q++= *p;

*q= '\0';

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

while(str1[i]!='')

{

i++;

}

while(str2[j]!='')

{

str2[j++]=str1[i++];

}

str2[j]='';

puts(str2);

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a program to join two strings?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a c program to copy two strings using pointers?

nahi malum


A Write the algorithm to concatenate two given strings?

a write the algorithm to concatenate two given string


Why do people say the phrase tie the knot to get married?

because when you tie a knot you join two strings together and when you get married you join the person you are marrying


How to write aC program to merge two singly linked list?

write a c program to circular queue


Write a program to compare two strings with out using strcmp function?

#include main() { //please read two strings int str1 and str2// while(str1[i]!='/0' &amp;&amp;str2[i]!='/0') if(str1[i]!=str2[i]) flag=1; if(flag==1) printf("equal"); } #include main() { //please read two strings int str1 and str2// while(str1[i]!='/0' &amp;&amp;str2[i]!='/0') if(str1[i]!=str2[i]) flag=1; if(flag==1) printf("equal"); }


Write a regular expression for binary strings with at least two 0s but not consecutive 0s.?

1*01+01*


Can you tell me a C program to find if the strings are equal using pointers?

It is called strcmp, part of the standard run-time library. Returns 0 if the two strings are equals, non-zero otherwise.


Write a program to add two 8 bit numbers in microprocessor 8051?

write it in 8085


Write a script that accepts two strings from the user and compare two strings in web technology?

how to compare two strings that take input from the user and compare it. For example: i give first string as "THE" and give second string as "HTE" then return "match" if i give first as"THE" nd second string as "EHI" then return "NOtMatch" witout using STRCMP ... please help me


What is the Program for compare two strings using OR operator in java?

The String class includes two helpful methods: equals and compareTo.string1.equals(string2) will return true if the two strings contain the exact same charactersstring1.compareTo(string2) will return an int which describes the lexicographic relationship between the two strings. It will return a negative value if string1 is "less than" string2, a positive value if string1 is "greater than" string2, or zero if the two are equivalent strings.


What did David's slingshot look like?

It was a pouch with two strings attached to it.


Write an assembly language program to multiply two BCD numbers?

fish