Plz help me with the characters showing.

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

  1. pinkfog

    pinkfog Guest

    hi,all
    I write a snippet(in VC6.0 PLATFORM) to show the ASCII character
    ranging from 0-255.
    snippet:
    #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);
    }
    getch();
    return 0;
    }


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

  2. pinkfog opined:

    > hi,all
    > I write a snippet(in VC6.0 PLATFORM) to show the ASCII character
    > ranging from 0-255.
    > snippet:
    > #include "stdafx.h"


    Don't know what this is (it's not Standard C), but you don't need it
    anyway.

    > #include "stdio.h"


    #include <stdio.h>

    > #include "conio.h"


    Not Standard C. Probably don't need this either.

    > int main(int argc, char* argv[])
    > {
    > int i = 0;


    Superfluous inititalisation, as you initialise it below.

    > for(i = 0; i < 255; i++)
    > {
    > printf("%d = %c\n", i, i);
    > }
    > getch();


    This is non-standard (comes from "conio.h"). What's wrong with the
    standard `getchar()`?

    > return 0;
    > }
    >
    >
    > IT can normaly show 0-127,but cannot show 128-255 just like "219=?".
    > what's the problem?


    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)

    <http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>
    Vladimir S. Oka, Apr 12, 2006
    #2
    1. Advertising

  3. pinkfog

    Ian Collins Guest

    pinkfog wrote:
    > hi,all
    > I write a snippet(in VC6.0 PLATFORM) to show the ASCII character
    > ranging from 0-255.
    > snippet:


    > #include "stdafx.h"

    What's this header for?

    > #include "stdio.h"


    prefer #include <stdio.h>

    > #include "conio.h"

    What's this header for?

    > int main(int argc, char* argv[])
    > {
    > int i = 0;
    > for(i = 0; i < 255; i++)
    > {
    > printf("%d = %c\n", i, i);
    > }
    > getch();

    Why?

    > return 0;
    > }
    >
    >
    > IT can normaly show 0-127,but cannot show 128-255 just like "219=?".
    > what's the problem?
    > Any one can help?


    Your locale's character set does not include these characters.

    --
    Ian Collins.
    Ian Collins, Apr 12, 2006
    #3
  4. pinkfog

    Guest

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

    Guest

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

    Guest

    pinkfog wrote:
    > hi,all
    > I write a snippet(in VC6.0 PLATFORM) to show the ASCII character
    > ranging from 0-255.
    > snippet:
    > #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);
    > }
    > getch();
    > return 0;
    > }
    >
    >
    > IT can normaly show 0-127,but cannot show 128-255 just like "219=?".
    > what's the problem?
    > Any one can help?
    > Thx.
    > -----------------pinkfog---------------


    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.
    , Apr 12, 2006
    #6
  7. pinkfog

    Guest

    wrote:
    > 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.


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

    osmium Guest

    "pinkfog" wrote:

    > I write a snippet(in VC6.0 PLATFORM) to show the ASCII character
    > ranging from 0-255.
    > snippet:
    > #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);
    > }
    > getch();
    > return 0;
    > }
    >
    >
    > IT can normaly show 0-127,but cannot show 128-255 just like "219=?".
    > what's the problem?


    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
    #8
  9. On 2006-04-12, pinkfog <> wrote:
    > hi,all
    > I write a snippet(in VC6.0 PLATFORM) to show the ASCII character
    > ranging from 0-255.
    > snippet:
    > #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);
    > }
    > getch();
    > return 0;
    > }
    >
    >
    > IT can normaly show 0-127,but cannot show 128-255 just like "219=?".
    > what's the problem?
    > Any one can help?
    > Thx.
    > -----------------pinkfog---------------
    >


    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
    #9
  10. pinkfog

    Default User Guest

    wrote:

    > charactor is only ranging from 0-127


    See below.



    Brian

    --
    Please quote enough of the previous message for context. To do so from
    Google, click "show options" and use the Reply shown in the expanded
    header.
    Default User, Apr 12, 2006
    #10
  11. pinkfog wrote:
    > hi,all
    > I write a snippet(in VC6.0 PLATFORM) to show the ASCII character
    > ranging from 0-255.


    There is no such thing. The ASCII character set is defined over 0-127.

    > snippet:
    > #include "stdafx.h"

    Not a standard header. Remove.

    > #include "stdio.h"

    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
    #include <stdio.h>

    > #include "conio.h"

    Not a standard header. Remonve

    > int main(int argc, char* argv[])
    > {
    > int i = 0;
    > for(i = 0; i < 255; i++)
    > {
    > printf("%d = %c\n", i, i);
    > }
    > getch();

    Not a standard function. Remove or replace with a standard
    function or macro. One such is getchar().

    > return 0;
    > }
    >
    >
    > IT can normaly show 0-127,but cannot show 128-255 just like "219=?".
    > what's the problem?


    You implementation seems use the ASCII characters set and know that
    it is defined only over the range of 0-127.

    > Any one can help?


    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
    ASCII.

    > Thx.


    Would it really have hurt your hand to type *two* more characters? Like
    this:
    Thanks
    Martin Ambuhl, Apr 12, 2006
    #11
  12. Martin Ambuhl opined:

    > pinkfog wrote:
    >
    >> Thx.

    >
    > Would it really have hurt your hand to type *two* more characters?
    > Like this:
    > Thanks


    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)

    <http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>
    Vladimir S. Oka, Apr 12, 2006
    #12
  13. Vladimir S. Oka wrote:
    > Martin Ambuhl opined:
    >
    >
    >>pinkfog wrote:
    >>
    >>
    >>>Thx.

    >>
    >>Would it really have hurt your hand to type *two* more characters?
    >>Like this:
    >> Thanks

    >
    >
    > It may have, as it's four more, *and* that "x" needs translating.


    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.
    Idiot.
    Martin Ambuhl, Apr 12, 2006
    #13
  14. Martin Ambuhl opined:

    You didn't strike me as the one to not get the joke...

    > Vladimir S. Oka wrote:
    >> Martin Ambuhl opined:
    >>
    >>
    >>>pinkfog wrote:
    >>>
    >>>
    >>>>Thx.
    >>>
    >>>Would it really have hurt your hand to type *two* more characters?
    >>>Like this:
    >>> Thanks

    >>
    >>
    >> It may have, as it's four more, *and* that "x" needs translating.

    >
    > The string "Thx." has 4 characters.


    I do admit not counting a ".".

    > 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.


    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.

    > Idiot.


    And that was totally uncalled for.

    Goodbye.

    --
    Either one of us, by himself, is expendable. Both of us are not.
    -- Kirk, "The Devil in the Dark", stardate 3196.1

    <http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>
    Vladimir S. Oka, Apr 12, 2006
    #14
  15. pinkfog

    Jack Klein Guest

    On Wed, 12 Apr 2006 17:37:45 +0200, "Richard G. Riley"
    <> wrote in comp.lang.c:

    > On 2006-04-12, pinkfog <> wrote:
    > > hi,all
    > > I write a snippet(in VC6.0 PLATFORM) to show the ASCII character
    > > ranging from 0-255.
    > > snippet:
    > > #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);
    > > }
    > > getch();
    > > return 0;
    > > }
    > >
    > >
    > > IT can normaly show 0-127,but cannot show 128-255 just like "219=?".
    > > what's the problem?
    > > Any one can help?
    > > Thx.
    > > -----------------pinkfog---------------
    > >

    >
    > 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.


    There are NO characters > 127 in Microsoft Visual C++ 6.0. The type
    "char" is signed, and ranges from -128 to 127.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://c-faq.com/
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
    Jack Klein, Apr 13, 2006
    #15
  16. pinkfog

    Flash Gordon Guest

    Jack Klein wrote:

    <snip>

    > There are NO characters > 127 in Microsoft Visual C++ 6.0. The type
    > "char" is signed, and ranges from -128 to 127.


    <OT>
    Unless you set the option to tell it to make char unsigned.
    </OT>
    --
    Flash Gordon, living in interesting times.
    Web site - http://home.flash-gordon.me.uk/
    comp.lang.c posting guidelines and intro:
    http://clc-wiki.net/wiki/Intro_to_clc
    Flash Gordon, Apr 13, 2006
    #16
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. brian

    Size of my Struct? PLZ PLZ reply

    brian, Nov 23, 2004, in forum: C Programming
    Replies:
    7
    Views:
    417
    -berlin.de
    Nov 25, 2004
  2. Replies:
    1
    Views:
    382
  3. Replies:
    2
    Views:
    336
    Nick Keighley
    Nov 24, 2006
  4. Replies:
    1
    Views:
    340
  5. nocturnal
    Replies:
    1
    Views:
    523
    nocturnal
    Jul 10, 2009
Loading...

Share This Page