-4

The code gives different outputs in gcc and in turbo c compiler. Why there is difference between ascii values in these compiler.

#include <stdio.h> int main() { int n=1; while (n<70){ printf("Ascii value is %c\n",n); n++; } return 0; } 

The above program gives different outputs for values, say from 1 - 16 or something like that in gcc and in turbo c. Why is it so?

1
  • 4
    The first 32 "characters" are not actually printable, what will be printable will depend on environment. I recommend you check an ASCII table to see which characters are actually printable. Or use the standard isprint function. Commented Jul 2, 2016 at 14:04

1 Answer 1

7

It's not the compiler, it's the console that displays those glyphs differently (the first 32 characters are non-printable). Glyphs 32 through 126 are guaranteed identical in all cases, though.

Sign up to request clarification or add additional context in comments.

4 Comments

This. Turbo C runs on a DOS emulator so this is almost certainly about output encoding.
Yes, and it almost certainly is not ASCII. Run chcp to find out what the terminal is using. (@Paul, CP437 does have printable characters <32.)
Yes I've seen VGA characters and even \n has an associated glyph instead of being newline (it becomes newline later)
And characters below 32 are nonprintable. While the console does display them, it's their choice entirely on how to represent them.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.