Write an implementation of “float stringToFloat(char *str).”
The code should be simple, and not require more than the
basic operators (if, for, math operators, etc.).
• Assumptions
• Don’t worry about overflow or underflow
• Stop at the 1st invalid character and return the number
you have converted till then, if the 1st character is
invalid return 0
• Don’t worry about exponential (e.g. 1e10), instead you
should treat ‘e’ as an invalid character
• Write it like real code, e.g. do error checking
• Go though the string only once
• Examples
• “1.23” should return 1.23
• “1a” should return 1
• “a”should return 0
Answer Posted / fernando
If I have character buffer with many floats and want to
separate it as I do?
Example:
for (uint8_t i = 0; i < n; i++)
{
buf [i]; 25.45, 26.54,...
}
buf[0]=
buf[1]=
.
.
.
buf[n]=
Thanks.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
I need testPalindrome and removeSpace
#include
What is c programming structure?
largest Of three Number using without if condition?
How the c program is executed?
What is the use of getchar() function?
what do u mean by Direct access files? then can u explain about Direct Access Files?
What is a program flowchart?
Write a program to print fibonacci series without using recursion?
Explain built-in function?
If errno contains a nonzero number, is there an error?
By using C language input a date into it and if it is right?
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
How do you view the path?
How do I determine whether a character is numeric, alphabetic, and so on?