Funciones de Cadena : Concatenar() - strcat() - concat()
Función que permite unir dos cadenas de texto.
💻 Hacer un programa que permita CONCATENAR o JUNTAR dos CADENAS ingresadas de forma individual.
Algoritmo programacion.work
Definir frase1, frase2 como Caracter;
Escribir "04. FUNCIÓN - JUNTAR DOS CADENAS. ";
Escribir "";
Escribir Sin Saltar "INGRESE FRASE 1 : ";
Leer frase1;
Escribir Sin Saltar "INGRESE FRASE 2 : ";
Leer frase2;
Escribir "CADENAS AGRUPADAS : ", Concatenar(frase1,frase2);
FinAlgoritmo
print("CONCATENAR O JUNTAR DOS PALABRAS")
frase1 = input("INGRESE TEXTO 1 : ")
frase2 = input("INGRESE TEXTO 2 : ")
print("CADENAS JUNTAS :", frase1+frase2)
Usando como tipo de dato : CHAR
#include<iostream>
#include<cstring>
#define MAX_STRLEN 256
using namespace std;
int main() {
char frase1[MAX_STRLEN];
char frase2[MAX_STRLEN];
cout << "INGRESE FRASE 1 : ";
cin >> frase1;
cout << "INGRESE FRASE 2 : ";
cin >> frase2;
strcat(frase1,frase2);
cout << "FRASES JUNTAS : " << frase1 << endl;
return 0;
}
Usando como tipo de dato : STRING
#include<iostream>
using namespace std;
int main() {
string frase1, frase2;
cout << "INGRESE FRASE 1 : ";
cin >> frase1;
cout << "INGRESE FRASE 2 : ";
cin >> frase2;
cout << "FRASES JUNTAS : " << frase1+frase2 << endl;
return 0;
}
package programacion.work;
import java.util.Scanner;
public class juntar_dos_textos {
public static void main(String[] args) {
Scanner ingreso=new Scanner(System.in);
String frase1,frase2;
System.out.print("INGRESE FRASE 1 : ");
frase1 = ingreso.nextLine();
System.out.print("INGRESE FRASE 2 : ");
frase2 = ingreso.nextLine();
frase1 = frase1.concat(frase2);
System.out.println("FRASES JUNTAS : " + frase1);
}
}