In C a char is an int. A char constant is really and truely an int, while a char is an 8 bit quantity that behaves like an int (and may be signed or not depending on compiler and options).
In Perl a char is a string containing a single character. Using a string in a numerical context 'numifies' the string - gets it interpreted as a number. The string constant 'c' turns into 0 when numified. Not what you want. What you need is to use the function ord which produces the ordinal value for the first character in the string passed to it.
In reply to Re: Getting the ascii number through perl's printf
by GrandFather
in thread Getting the ascii number through perl's printf
by jesuashok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |