|
Page 1 of 1
|
[ 3 posts ] |
|
| Author |
Message |
|
SciQuest_csp
Rookie
Joined: Tue Jan 17, 2012 5:39 pm Posts: 4
|
 Substrings
Hello, I am trying to write a text-command parser. Currently, I have a text file and read from it byte by byte. I compile this into an array of strings, with each string being delimited by spaces, commas, LR, CF, etc. As I go along I convert it to all lower case.
My problem is that some of these strings are numeric. Id like to take a string, such as "3.14", and turn it into a float. Given RobotC's string functions being what they are, what is the preferred way to do this?
I would really like to avoid having to do it while I am pulling the commands from the text file (in a char array), and instead do it while the command is being parsed (from a string).
|
| Mon Mar 19, 2012 3:15 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 Re: Substrings
Try atof()  - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Mon Mar 19, 2012 3:36 pm |
|
 |
|
SciQuest_csp
Rookie
Joined: Tue Jan 17, 2012 5:39 pm Posts: 4
|
 Re: Substrings
I cant believe I skipped over the very first function in the documentation.
EDIT: Oh, I was on an (rather) old version of RobotC, that explains it.
|
| Mon Mar 19, 2012 4:46 pm |
|
|
|
Page 1 of 1
|
[ 3 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|