Plz help me with the characters showing.

P

pinkfog

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

Vladimir S. Oka

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 said:
#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>
 
I

Ian Collins

pinkfog said:
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 said:
#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.
 
S

slebetman

pinkfog said:
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.
 
S

slebetman

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

osmium

pinkfog said:
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.
 
R

Richard G. Riley

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

Martin Ambuhl

pinkfog said:
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 said:
#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.

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

Martin Ambuhl

Vladimir said:
Martin Ambuhl opined:




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

Vladimir S. Oka

Martin Ambuhl opined:

You didn't strike me as the one to not get the joke...
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.

And that was totally uncalled for.

Goodbye.
 
J

Jack Klein

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

Flash Gordon

Jack Klein wrote:

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>
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top