Ma fonction ne retourne pas une chaine

Fermé
ZeRo0Cold Messages postés 10 Date d'inscription lundi 20 juin 2011 Statut Membre Dernière intervention 27 janvier 2012 - 9 déc. 2011 à 16:52
Bonjour,





J'ai un problème a ma fonction je sais pas comment retourner une chaine
voici ma fonction qui calcule la somme de deux nombres chaines

#include<stdio.h>
#include<conio.h>

char* somme(char* t1, char* t2,char* ch )
{int l1,l2,k;

l1=strlen(t1);
l2=strlen(t2);
char R='0';
int i=0,j=0,s1=0,s2=0,f1=0,f2=0;

while (t1[i]!='.')
{s1++;i++;}
while (t2[j]!='.')
{s2++;j++;}

if (s1<s2)
{
for (i=l1-1+(s2-s1),j=l1-1;j>=0;i--,j--)
{
t1[i]=t1[j];
}
t1[l1+s2-s1]=0;

for(i=0;i<s2-s1;i++)
t1[i]='0';
l1=l1+(s2-s1);
}
else
{
for (i=l2-1+(s1-s2),j=l2-1;j>=0;i--,j--)
{
t2[i]=t2[j];
}
t2[l2+s1-s2]=0;

for(i=0;i<s1-s2;i++)
t2[i]='0';
l2=l2+(s1-s2);
}

i=l1-1;
while (t1[i]!='.')
{
f1++;i--;
}
j=l2-1;
while (t2[j]!='.')
{
f2++;j--;
}

if (f1<f2)
{
for(i=l1;i<l1+(f2-f1);i++)
t1[i]='0';
l1=l1+(f2-f1);
t1[l1]=0;
}

else
{
for(i=l2;i<l2+(f1-f2);i++)
t2[i]='0';
l2=l2+(f1-f2);
t2[l2]=0;
}
int l3=l1+1;
ch[l3]=0;


for(i=l1-1,j=l2-1,k=l3-1;i>=0;i--,j--,k--)
{
if (t1[i]!='.'&&t2[j]!='.')
{
ch[k]=t1[i]+t2[j]-48+(R-48);

if (ch[k]>'9')
{
ch[k]=ch[k]-('9'+1)+48;
R='1';
}
else
R='0';
}
else
ch[k]='.';
}
ch[k]=R;

return *ch;
}

main()
{
char t1[]="84444.23";
char t2[]="300.9234";
char t3[50],t4[50];
strcpy(t4,somme(t1,t2,t3));
printf(" ");puts(t1);
printf(" ");puts(t2);
puts(t4);

getch();

}

j'ai compiler le programme et il affiche un message d'erreur autant de exécution;

aider moi svp;

merci