Print Extended ASCII in ANSI C

Joined
Nov 21, 2014
Messages
1
Reaction score
0
The warning issued by the compiler is quite natural as the for loop you have made is unending.
unsigned char can take values upto 0 to 255. Now when you add 1 to this, it takes up some negative value and since that negative value is always less than 255, you get a glitch. What I suggest is, print upto 254 and then, outside the for loop print ASCII character 255.
Hope this helps!
santosh wrote:
> ramif wrote:
>
>> Is there a way to print extended ASCII in C??

>
> There is no guarantee to even print the ASCII characters as C is
> character encoding agnostic, except for the fact that a certain basic
> set of characters must be available and that the value of characters in
> the range 0... 9 must be continuous.
>
>> I tried to code something, but it only displays strange symbols.

>> here is my code:
>>
>> main()
>> {
>> char chr = 177; //stores the extended ASCII of a symbol
>> printf("Character with an ascii code of 177: %c \n", chr);
>> //tries to print an ASCII symbol...
>>
>> return 0;
>> }
>
> If you are sure that your machine as support for extended characters
> try:
>
> #include <stdio.h>
>
> int main(void) {
> unsigned char c;
>
> for (c = 32; c <= 255; c++) putc(c, stdout);
> return 0;
> }
>


I tried your code, and gcc gave me the following warning:
"warning: comparison is always true due to limited range of data type"

BTW, i'm using Linux Fedora 7 running on x86_64 architecture. GCC
version is 4.1.2 20070925

Do you think that my PC supports extended ASCII??

A few month ago, i've written a Pascal program (on Windows XP) that
displays the extended ASCII and it worked without any problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,829
Latest member
PIXThurman

Latest Threads

Top