```
int main()
{
char inputstr[] = "123.45";
float result= 0.0f;
size_t len = sizeof(inputstr)-1;
size_t dotpos = 0;
for (size_t n = 0; n < len; n++)
{
if (inputstr[n] == '.')
{
dotpos = len - n - 1;
}
else
{
result = result * 10.0f + (inputstr[n]-'0');
}
}
while ( dotpos--)
{
result /= 10.0f;
}
printf("%f\n",result);
}
```

12,065,102 members (45,711 online)

Email

Password

Sign in using

Write out your algorithm and check against code.

The debugger is your friend.

temp=inputstr[i] - '0';

When inputstr[i] is a '.' (period) :)

for(i=0;i<=4;i++)