|
From: Reid T. <Rei...@at...> - 2005-01-10 16:21:46
|
Per Westermark wrote:
> On Mon, 10 Jan 2005, Reid Thompson wrote:
>>=20
>> man atoi
>>=20
>> reid
>=20
> Confusion??? atoi converts "123" to 123 but it doesn't
> convert 'A' to a number - or actually it gets 'converted' to the
> value 0...=20
>=20
> /Per W
sorry - answered too quickly ---=20
#include <stdio.h>
int main(void)
{
char mychar =3D 'A';
char temp[8];
int ifromc =3D 0;
snprintf(temp, sizeof(temp), "%d", mychar);
printf("%s\n", temp);
ifromc =3D atoi(temp);
printf("%d\n", ifromc);
return(0);
}
reid
|