2015-08-18 08:06 PM
I want to recieve data From Visual Studio. (UART)
Visual Studio send data 'SDC 50.0' // SDC 50.0 is charI want 50.0 only but I don't need SDC Iwant 50.0 to take it something About intergerPlease Help me2015-08-18 08:57 PM
So can't you just parse one character at a time multiplying by 10?
integer or float?Thought about atoi(), atof() or sscanf() ??2015-08-18 09:06 PM
Hi,
This is more of a basic programming question.Have you tired to google? It's something you really should learn to do more and learn to filtrate all the info available.First result from a search with ''char to int'':http://stackoverflow.com/questions/5029840/convert-char-to-int-in-c-and-cIf it's possible to not have it beginning with letters you can use the function ''atoi''.or if it's always 3 leters before you can just do ''str+3'' and you will have a string starting on that 5. The problem I see right there is, you do know that is not a int right? It has a decimal number (even though it's 0 here).''atof'' function should work on doubles and floats but note that is not exactly efficient, and you will still need to give that function a string starting with the numbers.Maybe you making your how methods would be better. Just check if the char is a letter or a number, when you reach the number just start converting to int until you get to the ''.'', then the rest is decimal numbers. C'mon that was like the most common exercise in my first semester of programming and will surely be better for a microcontroller if employed correctly. You should avoid using things like sprintf, functions that are used a lot when manipulating strings in a computer in programming classes.2015-08-19 12:15 AM
Sorry, It's float