Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How macro execution is faster than function ?

1204


What do you understand by normalization of pointers?

1068


Which is better pointer or array?

1037


What is #define used for in c?

1068


What is c++ used for today?

1111


Why can’t constant values be used to define an array’s initial size?

1390


all c language question

2449


Who is the founder of c language?

1173


Can two or more operators such as and be combined in a single line of program code?

1377


How can a string be converted to a number?

1024


What is memory leak in c?

1135


Why we use int main and void main?

1090


Is exit(status) truly equivalent to returning the same status from main?

1077


How is pointer initialized in c?

1033


What is "Hungarian Notation"?

1121