Convert an char array to one float value?
-
hi i have any array of chararctaers that reresent a speed for example char a[3]={0,.,9} i want to convert this array to a float value .. that is float b=0.9 i havea function that convert an array with only number to an integer value i cant find any that would do what i want ??
-
Answer:
It would help greatly if you tell us which language you are programming in (I will update my answer depending on what language you specify) Edit: Sorry, I don't know C I do know c++ though but that's entirely different isn't it. :( If you know how to use pointers though, I would reccomend finding out what a float consists of as pure memory address and it's usual length. That way you can write directly to the memory. Obviously this isn't safe.
Fatima at Yahoo! Answers Visit the source
Other answers
Convert the array into a string. Use a loop and concatenation. Then convert the string to a float. If I knew what language you were using I could offer more help. Additional: char a[3]={'0', '.', '9'}; double f = atof(a); Have fun.
AnalProgrammer
Related Q & A:
- How can I change a value in an array?Best solution by Stack Overflow
- How to pass javascript jQuery variable value in php array?Best solution by Stack Overflow
- How to convert a char array into an int in C++?Best solution by Stack Overflow
- How to convert from string to char in C++?Best solution by Stack Overflow
- Converting char array to double in C?Best solution by stackoverflow.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.