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
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
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.
How do I convert a stl file?
What are stl algorithms?
Explain stl.
What does stl mean in slang?
Describe how to safeguard a system through acquisition of an antivirus Program and systematic backup.
What is stl stack?
What is stl in c++ with example?
what is template and type convertion
What are the various types of stl containers?
What is stl stand for?
Is stl open source?
Name the different types of stl containers.
how to use C++?