2
include
int main(){
void concatenarStrings(char string1[], int t1,
char string2[], int t2,
char string3[]);
char palavra1[]={'p','a','o','c','o','m'};
char palavra2[]={'m','o','r','t','a','d','e','l','a'};
char novaPalavra[16];
concatenarStrings(palavra1,6,palavra2,9,novaPalavra);
int i;
for(int i = 0;i < 1;++i){
printf("%c",novaPalavra[i]);
}
return 0;
}
void concatenarStrings(char string1[], int t1,
char string2[], int t2,
char string3[]){
int i,j;
for(i = 0; i < t1; ++i){
string3[i] = string1[i];
}
for(j = 0; j < t2; ++j){
string3[t1 + j] = string2[j];
}
}
My above code compiles correctly in DEV C++, does not present any error. It is a code to concatenate the string word1 and word2, but always when I run it, instead of forming the word pao with mortadella, it displays only the word p. I can’t see where the mistake is.
Thank you very much.
– Marco Aurélio Lopes Júnior