View unanswered posts | View active topics It is currently Mon Sep 22, 2014 10:29 am

Reply to topic  [ 3 posts ] 
Author Message

Joined: Tue Jan 17, 2012 5:39 pm
Posts: 4
Post 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
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post Re: Substrings
Try atof() :)

- Xander

| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]

Mon Mar 19, 2012 3:36 pm
Profile WWW

Joined: Tue Jan 17, 2012 5:39 pm
Posts: 4
Post 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
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: tmalecek and 1 guest

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

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.