Plz help me with the characters showing.

Discussion in 'C Programming' started by pinkfog, Apr 12, 2006.

  1. pinkfog

    pinkfog Guest

    I write a snippet(in VC6.0 PLATFORM) to show the ASCII character
    ranging from 0-255.
    #include "stdafx.h"
    #include "stdio.h"
    #include "conio.h"
    int main(int argc, char* argv[])
    int i = 0;
    for(i = 0; i < 255; i++)
    printf("%d = %c\n", i, i);
    return 0;

    IT can normaly show 0-127,but cannot show 128-255 just like "219=?".
    what's the problem?
    Any one can help?
    pinkfog, Apr 12, 2006
    1. Advertisements

  2. pinkfog opined:
    Don't know what this is (it's not Standard C), but you don't need it
    Not Standard C. Probably don't need this either.
    Superfluous inititalisation, as you initialise it below.
    This is non-standard (comes from "conio.h"). What's wrong with the
    standard `getchar()`?
    ASCII characters are only the ones with codes 0-127. The other problem
    is in the setup of your console. Obviously it does not know how to
    display all the codes (or you think they should display differently).
    Not a C issue, so you may want to ask elsewhere.

    "The IETF motto is 'rough consensus and running code'"

    -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates)

    Vladimir S. Oka, Apr 12, 2006
    1. Advertisements

  3. pinkfog

    Ian Collins Guest

    What's this header for?
    What's this header for?
    Your locale's character set does not include these characters.
    Ian Collins, Apr 12, 2006
  4. pinkfog

    jefong Guest

    the ASCII character is only rangin from 0-127.
    jefong, Apr 12, 2006
  5. pinkfog

    jefong Guest

    charactor is only ranging from 0-127
    jefong, Apr 12, 2006
  6. pinkfog

    slebetman Guest

    Well... my favourite text editor already does what your program do and
    does it live while I'm editing code. On top of that it also
    *highlights* the relevant line when the cursor is on either the opening
    or closing brace {}. On top of that it does syntax highlighting. On top
    of that it also allows me to fold sections of code to temporarily hide
    things I'm not interested in (and remember this is "live" while I'm
    editing). And to top it all off it can print, save as RTF save as PDF
    and save as HTML the nicely formatted code along with the nice lines.
    The only difference is that my editor draws lines based on indentation
    while your program auto-indent and draws lines based on braces. But
    that's OK, that's what "indent" is for. Oh and yes my editor supports
    syntax of more than 40 different languages.
    slebetman, Apr 12, 2006
  7. pinkfog

    slebetman Guest

    Oh crap posted on the wrong thread. Ignore this, sorry... very, very
    slebetman, Apr 12, 2006
  8. pinkfog

    osmium Guest

    The problem is with VC 6.0. The essential core of your program does what
    you want in DevC (MingW). It shows the old MS-DOS era glyphs for 128 to
    255. Try posting your question where VC is topical. I have it on my
    machine but I never used it and don't want to use it.
    osmium, Apr 12, 2006
  9. Look up "locale" and how character sets work. The characters > 127 can
    be all sorts of wierd and wonderful things and will depend on the
    platform, location, window, locale setting and installed fonts.
    Richard G. Riley, Apr 12, 2006
  10. pinkfog

    Default User Guest

    See below.

    Default User, Apr 12, 2006
  11. There is no such thing. The ASCII character set is defined over 0-127.
    Not a standard header. Remove.
    Unless you have your own personal copy of stdio.h that you intend to
    use, this is not the right way to include a standard header, Use
    Not a standard header. Remonve
    Not a standard function. Remove or replace with a standard
    function or macro. One such is getchar().
    You implementation seems use the ASCII characters set and know that
    it is defined only over the range of 0-127.
    Perhaps you should start by learning standard C. Then learn that your
    code does not necessarily relate to ASCII at all; other encodings are
    possible. In fact, you seem to want some other encoding, since you want
    to display characters for values which are outside the defined range of
    Would it really have hurt your hand to type *two* more characters? Like
    Martin Ambuhl, Apr 12, 2006
  12. Martin Ambuhl opined:
    It may have, as it's four more, *and* that "x" needs translating.

    "...Unix, MS-DOS, and Windows NT (also known as the Good, the Bad, and
    the Ugly)."
    (By Matt Welsh)

    Vladimir S. Oka, Apr 12, 2006
  13. The string "Thx." has 4 characters.
    The string "Thanks" has 6 characters.
    In your arithmetic the value of 6-4 may be 4, but don't bother applying
    for work anywhere that uses numbers.
    Martin Ambuhl, Apr 12, 2006
  14. Martin Ambuhl opined:

    You didn't strike me as the one to not get the joke...
    I do admit not counting a ".".
    Now, still not counting the ".":

    "Thx" differs from "Thanks" in 4 characters ("anks"), possibly 5 if you
    count the "x" (that needs translating into "anks"). So, it does
    require typing 4 extra characters ("anks"), and, if you want to be
    very precise, one less ("x"), in which case we're both wrong, as it's
    3, not 2 or 4.
    And that was totally uncalled for.

    Vladimir S. Oka, Apr 12, 2006
  15. pinkfog

    Jack Klein Guest

    There are NO characters > 127 in Microsoft Visual C++ 6.0. The type
    "char" is signed, and ranges from -128 to 127.
    Jack Klein, Apr 13, 2006
  16. pinkfog

    Flash Gordon Guest

    Jack Klein wrote:

    Unless you set the option to tell it to make char unsigned.
    Flash Gordon, Apr 13, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.