answersLogoWhite

0


Best Answer

#include<iostream>

#include<string>

int main()

{

using std::string;

string a = "hand";

string b = "bag";

string c = a + b; // concatenation

}

User Avatar

Wiki User

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

Wiki User

13y ago

Using Java:

class concat

{

public static void main(Strig Args[])

{

String str1 = "Wel";

String str2 = "Come";

String str3 = str1 + str2;

System.out.println("Concatenated:" + str3);

}

}

Using C:

#include <stdlib.h>

#include <stdio.h>

int main()

{

const char str1 [] = "Wel";

const char str2 [] = "Come";

char str3 [128], *p, *q;

q= str3;

for (p= str1; *p; ++p) *q++ = *p;

for (p= str2; *p; ++p) *q++ = *p;

*q= '\0';

printf("%s", str3);

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

#include<iostream>

char* concat(char* str1, char* str2)

{

int len1 = strlen(str1);

int len2 = strlen(str2);

char * str = ( char* ) malloc( len1+ len2 + 1 );

char * ptr = str + len1;

memcpy( str, str1, len1 );

memcpy( ptr, str2, len2 + 1 );

ptr = NULL;

return( str );

}

int main()

{

char string1[] = "This is the first string";

char string2[] = " and this is the second string.";

char* string3 = concat( string1, string2 );

std::cout<<string3<<std::endl;

free( string3 );

return(0);

}

This answer is:
User Avatar

User Avatar

Wiki User

16y ago

If you have let's say string1 = "blablabla1" and string2 = "blablabla2". To concatenate 2 strings you can use simbol +. So, string1 + string2 will be one string.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

p1= from1;
p2= from2;
q= to;

while ((*q++= *p1++)!='\0');
--q;
while ((*q++= *p2++)!='\0');

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Program to concatenate the two strings without using build in functions?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you concatenate two strings without using strcat?

Example1:sprintf (to, "%s%", from1, from2);Example2:size_t len1= strlen (from1);memcpy (to, from1, len1);strcpy (to+len1, from2);


What is the importance of using functions in a c program?

C programs do not function without functions.


What is the importance of functions in a c plus plus program?

Functions are very important in C++, as you can't write the simplest program to print hello without using a function. Overall you can say that function are building blocks of a C++ program. Functions can also be defined by the programmer to reduce program size.


Can you compile program without header file?

Yes,we can compile our program without header file without any error,but we can not use any predefine functions like printf,scanf.


What is a program for finding sqareroot of a number without using functions?

you read the book how to solve by dromy.


How do you link a C plus plus program to C functions?

It should work without any special action.


where can I find business grants without government strings attached?

where can I get a business grant without government strings attached?


How do you get a char from the keyboard in your C program without waiting?

OS-dependent. For DOS use functions kbhit and getch from conio.h


Write a program in C without any functions?

It is not possible. In C, any program must have at least one function to be able to compile and execute properly: the function main()


How many functions in c progamming?

One or more. (In other words: you cannot write a program without at least one function.)


What is the most important part of the violin?

Well I think the strings are as you cannot play the violin without the strings. from the belt man. Also the sound post in the violin is a major player in the sound making process


What is a violin without strings?

A broken violin.