Copiare la seconda parola di una stringa s1[] e la terza parola di una stringa s2[] in una terza stringa s3[] con il prototipo int unisci stringhe (chars1[], chars2[], char s3[]).E deve restituire come risultato la lunghezza di s3[]
Io ho inserito questo codice ma dubito che vada.
main(){
p[30], q[30], k[30];
int unisci_stringhe (char s1[] , char s2[] , char s3[]);
/*printf("%d",unisci_stringhe("e arrivato autunno","e il primo giocatore","arrivato primo"));
system("pause");*/
}
int unisci_stringhe (char s1[] , char s2[] , char s3[]){
int i=0, j=0;
int p=0 ,k=0 ,z=0;
int contas1=0 , contas2=0;
while(s1[i]!='\0'){
while(s2[j]!='\0'){
while(!contas1==1){
if(i>0 && s1[i]==' ' && s1[i-1] !=' ')
{contas1 ++;}
}
while(!contas2==2){
if(j>0 && s2[j]==' ' && s2[j-1] !=' ')
{contas2 ++;}
}
i++;j++;
}
}
{k=i+1; p=1, z=j+1;
while(s1[i]!=' ' || s1[i]!='\0'){
s3[p]=s1[i];
k++;
p++;}
while(s2[z]!=' ' || s2[z]!='\0'){
s3[p]=s2[z];
p++;
z++;
}
}
s3[p+1]='\0';
return p;
}