electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

How to convert ASCII characters into numeric values in KEIL


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> How to convert ASCII characters into numeric values in KEIL
Author Message
te04-0202



Joined: 17 Jun 2008
Posts: 17
Helped: 1


Post18 Jun 2008 5:54   

keil itoa


How to convert ASCII characters into numeric values in KEIL COMPILER.
Back to top
mostafahk



Joined: 28 May 2008
Posts: 19
Helped: 2
Location: tehran


Post18 Jun 2008 9:03   

keil ascii to character


if you want to convert a single character :

Code:

char c = '5';
int a = c - '0'; // now a = 5


if you want to convert an ascii array:
Code:

int a = 0;
char num[] = {'1' , '9' , '3' };

a = conv( num , 3 ); // now ans=193
.
.
.
int conv( char arr[] , char len )
{
    int ans = 0;
    char i;
    for( i = 0 ; i < len; i++ )
    {
        ans *= 10;
        ans += arr[i]-'0';
    }
    return ans;
}
Back to top
sureshreddy



Joined: 12 May 2008
Posts: 50
Helped: 4
Location: BANGLORE


Post19 Jun 2008 12:44   

character ascii keil c


te04-0202 wrote:
How to convert ASCII characters into numeric values in KEIL COMPILER.



HAI,
you can use below a to i function in keil also.nothing wrong.
int i;
char s [] = "12345";

i = atoi (s);
Back to top
te04-0202



Joined: 17 Jun 2008
Posts: 17
Helped: 1


Post22 Jun 2008 12:50   

keil char to ascii


How to convert an integer into character.
Back to top
Help



Joined: 15 Feb 2005
Posts: 560
Helped: 4


Post22 Jun 2008 16:17   

keil get ascii code


Hi,

I think you can try to use the fomula.
Code:
No = No * 10 + ch - '0';

Good Luck.
Back to top
Google
AdSense
Google Adsense




Post22 Jun 2008 16:17   

Ads




Back to top
sureshreddy



Joined: 12 May 2008
Posts: 50
Helped: 4
Location: BANGLORE


Post24 Jun 2008 4:52   

Re: How to convert ASCII characters into numeric values in K


te04-0202 wrote:
How to convert an integer into character.



HAI,
for this you have to use itoa.
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> How to convert ASCII characters into numeric values in KEIL
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
convert ASCII characters to keyboard scan codes (8)
How to convert ASCII into different language(chinese,Urdu) (3)
wanna convert values into centigrade (6)
How to convert -12V into +5V ? i.e., a -ve voltage into +ve (6)
How to convert 'real' values to std_logic_vector ? (8)
How to convert PADS into Allegro (1)
how to convert heat into electricity (8)
How to convert inductor into microstip? (5)
How to convert an integer into character in C++ (5)
how to convert the hspice_model into spectre_model? (4)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS