Write a program in C++ to concatenate two strings into third
string using pointers
Answer Posted / naman patidar
#include <iostream.h>
#include <string.h>
void main(){
char *str1 = "First String";
char *str2 = "Second String";
int len = strlen(str1)+strlen(str2)+1;
char *result = new char[len];
int i ;
for( i =0 ; i<strlen(str1); i++){
result[i] = str1[i];
}
for(int j=0; j<strlen(str2); j++, i++) {
result[i] = str2[j];
}
result[i] ='\0';
cout<<result;
}
Is This Answer Correct ? | 88 Yes | 58 No |
Post New Answer View All Answers
i wanted to know about questions about c,c++ , which is required for placements.... im a fresher
Why should a c++ programmer be interested in stl?
a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.
What does stl mean in slang?
What two types of containers does the stl provide?
What is stl stack?
What is stl in c++ with example?
How do I convert a stl file?
write a program that will accept a number and print.its equivalent in words the maximum input number is 9999
In what scenario does the Logical file and Physical file being used?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
Can we use stl in coding interviews?
What is stl language?
write a program to convert a decimal number in to its equivalent binary number?
how can u do connectivity in c++ language? plz send me connectivity code in c++ ?