Advertisement
any15015

Prog2tp2Ej1(opcion3)

Mar 25th, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include<iostream>
  2. #include <locale>
  3. #include<string.h>
  4. using namespace std;
  5.  
  6. void concatenar(char dest[], char orig[]);
  7.  
  8. int main(void)
  9. {
  10.     setlocale(LC_ALL, "Spanish");
  11.  
  12.     char e[50]="buen dia", f[9]="como va?";
  13.  
  14.     concatenar(e, f);
  15.  
  16.     return 0;
  17. }
  18.  
  19.  
  20. void concatenar(char dest[], char orig[]){
  21.      int i=0, j=0, x=0;
  22. while(dest[i]!='\0'){
  23.     i++;
  24. }
  25.  
  26. while(orig[j]!='\0'){
  27.     i++;
  28.     *(dest+i) = *(orig+j);
  29.     j++;
  30. }
  31.  
  32.  
  33. //con este codigo SI, muestra la concatenacion:
  34. for(int x=0; x<i; x++){
  35.      cout << *(dest+x);
  36. }
  37. cout << endl;
  38.  
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement