| Author |
Message |
te04-0202
Joined: 17 Jun 2008 Posts: 17 Helped: 1
|
18 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
|
18 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
|
19 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
|
22 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
|
22 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

|
22 Jun 2008 16:17 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
sureshreddy
Joined: 12 May 2008 Posts: 50 Helped: 4 Location: BANGLORE
|
24 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 |
|
 |