hi leute!
kann mir vielleicht irgendjemand sagen wie ich eine dezimalzahl wie z.B. 234 in das ASCII format konvertieren kann? kleiner c source code wäre super! danke im voraus
Decimal to ASCII
Re: Decimal to ASCII
Da gibt's nicht viel zu konvertieren, wenn ich Dich nicht völlig falsch verstehe...
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
void main (void)
{
char c;
int i = 234;
c = (char)i;
printf ("%c\<!--no-->n",c);
exit (0);
}
</font><hr></pre></blockquote>
Ungefähr so? Das Casten ((char)i) dürftest Du Dir im allgemeinen sogar sparen können... Also nix mit gross konvertieren. Bei EBCDIC sähe das schon anders aus... <img src="http://www.pl-forum.de/UltraBoard/Images/Happy.gif" border="0" align="middle">
Jochen
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
void main (void)
{
char c;
int i = 234;
c = (char)i;
printf ("%c\<!--no-->n",c);
exit (0);
}
</font><hr></pre></blockquote>
Ungefähr so? Das Casten ((char)i) dürftest Du Dir im allgemeinen sogar sparen können... Also nix mit gross konvertieren. Bei EBCDIC sähe das schon anders aus... <img src="http://www.pl-forum.de/UltraBoard/Images/Happy.gif" border="0" align="middle">
Jochen
Re: Decimal to ASCII
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
void myItoa(int value, char* string, char stringWidth)
{
for (int k=stringWidth-1; k>=1; k--)
{
string[k] = abs(value % 10);
value /= 10;
}
}
</font><hr></pre></blockquote>
Oder so (kann sein, dass string-Übergabe nicht ganz stimmt).
void myItoa(int value, char* string, char stringWidth)
{
for (int k=stringWidth-1; k>=1; k--)
{
string[k] = abs(value % 10);
value /= 10;
}
}
</font><hr></pre></blockquote>
Oder so (kann sein, dass string-Übergabe nicht ganz stimmt).