By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

Plz help me with the characters showing.

P: n/a
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---------------

Apr 12 '06 #1
Share this Question
Share on Google+
15 Replies


P: n/a
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>

Apr 12 '06 #2

P: n/a
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.
Apr 12 '06 #3

P: n/a
the ASCII character is only rangin from 0-127.

Apr 12 '06 #4

P: n/a
charactor is only ranging from 0-127

Apr 12 '06 #5

P: n/a
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 '06 #6

P: n/a
sl*******@yahoo.com 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 '06 #7

P: n/a
"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.
Apr 12 '06 #8

P: n/a
On 2006-04-12, pinkfog <ch*******@gmail.com> 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.

Apr 12 '06 #9

P: n/a
je****@56.com 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.
Apr 12 '06 #10

P: n/a
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
Apr 12 '06 #11

P: n/a
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>

Apr 12 '06 #12

P: n/a
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.
Apr 12 '06 #13

P: n/a
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>

Apr 12 '06 #14

P: n/a
On Wed, 12 Apr 2006 17:37:45 +0200, "Richard G. Riley"
<rg****@gmail.com> wrote in comp.lang.c:
On 2006-04-12, pinkfog <ch*******@gmail.com> 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/~a...FAQ-acllc.html
Apr 13 '06 #15

P: n/a
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
Apr 13 '06 #16

This discussion thread is closed

Replies have been disabled for this discussion.