[email protected]
Joined: 30 Nov 2008 Posts: 5
|
Help parsing a string |
Posted: Fri Apr 03, 2009 8:27 pm |
|
|
I have a project that has an SDCARD. I have a FAT file system. I need to open a text file and read in some values.
I have all the file stuff working and I can read in strings, and I can parse the string, the problem is I cannot figure out how to convert the string value to hex.
Here is my sample code.
Code: |
while (readln(&fdata,linein,63))
{
strcpy (temp_str, "\0");
strncpy (temp_str, linein + 5 , 4);
strcpy (temp_str + 4, "\0");
//Copy up to n characters s2->s1
EM_Timer_Settings[Loop_Counter] = atoi(temp_str);
|
The atoi func works if my number has hex chars. But if no hex chars, it converts the string to decimal.
what is the best way to convert a 4 char string to hex? |
|