/**
5. Faça um programa que receba 2 strings (A e B) e
retorne uma terceira string (C) formada pelos caracteres de A e B intercalados.
Ex.: Se A='Quarta' e B='Segunda', a resposta deve ser 'QSueagrutnada'
**/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
main(){
char s1[30], s2[30], s3[60];
int i=0, tamanho=0;
printf("String 1: ");
scanf(" %s", s1);
printf("String 2: ");
scanf(" %s", s2);
tamanho = strlen(s1) + strlen(s2);
for(i; i < tamanho; i++){
if(s3[i]%2 == 0){
s3[i] = s1[i];
}else{
s3[i] = s2[i];
}
}
printf(" %s", s3);
}
The result I've done so far is this, I thought - I'll concatenate a letter in the even position and another letter in the odd position but in logic it did not stay as I imagined it.
I know that in C I learned about the strcat()
function, but I do not know how to apply it in this example.