```
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);
}
```

13,050,429 members (78,465 online)

Email

Password

Sign in with

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++)