CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Conversion characters to string

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chandrshekar411



Joined: 14 Feb 2013
Posts: 9

View user's profile Send private message

Conversion characters to string
PostPosted: Wed Feb 27, 2013 10:58 pm     Reply with quote

I have the data like
the characters are stored in array
and data_arr() is the array name
Code:

data_arr[0]='1';// char 1
data_arr[1]='2';// char 2
data_arr[2]='.; // char . i.e decimal
data_arr[3]='3'; // char 3

I have to convert this to a float value
like float n=12.3
How can I convert characters to float value?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 27, 2013 11:30 pm     Reply with quote

Look at the atof() function in the CCS manual. This function requires a
string as the input, so your ascii float array must have a 0x00 byte at
the end of the numbers. This makes it into a C string. Example:
Code:
data_arr[4]=0x00;
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group