I have following questions:
1. Appendix C of K&R says:
Trigraph sequences introduced by ?? allow
representation of characters lacking in some
character set. ...
Can somebody explain how trigraphs are used?
2. What `entry' keyword was used for?
3. How to support colored output in C? For example,
Turbo C/C++ provides textattr () and textcolor ()
library routines to support it.
Thanks.
Vijay Kumar R Zanvar
--------------------------------------------
On Tue, 4 Nov 2003 09:52:03 +0530, "Vijay Kumar R Zanvar"
<vijaykumar.rz@globaledgesoft.com> wrote in comp.lang.c:
> I have following questions:
>
> 1. Appendix C of K&R says:
> Trigraph sequences introduced by ?? allow
> representation of characters lacking in some
> character sets. ...
>
> Can somebody explain how trigraphs are used?
Pass.
> 2. What `entry' keyword was used for?
Some C compilers prior to the standard implemented that keyword.
Since it was never part of any version of the C standard, it has no
defined standardized meaning. So it was used for whatever the
compiler implementor wanted to use it for.
> 3. How to support colored output in C? For example,
> Turbo C/C++ provides textattr () and textcolor ()
> library routines to support it.
Use compiler-specific non-standard extensions provided by whatever
compiler you are using, just as you did those with Turbo C. Since C
does not define, support, or require a video display, it has no
support for color.
> Thanks.
--
Jack Klein
-------------------------------------------------------
"Vijay Kumar R Zanvar" <vijaykumar.rz@globaledgesoft.com> wrote in message
news:bo79gc$1a1uu1$1@ID-203837.news.uni-berlin.de...
> I have following questions:
>
> 1. Appendix C of K&R says:
> Trigraph sequences introduced by ?? allow
> representation of characters lacking in some
> character sets. ...
>
> Can somebody explain how trigraphs are used?
>
Just like it says in K&R: to make up for characters not existing in a
specific
codepage. The only example I know is certain mainframe computers that don't
have the characters [ and ] in their codepage (along with some less
frequently used characters). These characters should be expanded in ??( and
??) respectively before uploading.
If you want to write truly compatibel C code, your lines should be within 80
characters
AFTER trigraph expansion. If you don't intend to port to older mainframes, I
wouldn't know why you should bother.
---------------------------------------------------------
"pzinnc296" <pzinnc296@rogers.com> wrote in message
news:SUGpb.176863$3f.152336@twister01.bloor.is.net.cable.rogers.com...
[..]
> Just like it says in K&R: to make up for characters not existing in a
> specific
> codepage. The only example I know is certain mainframe computers that
don't
> have the characters [ and ] in their codepage (along with some less
> frequently used characters). These characters should be expanded in
??( and
> ??) respectively before uploading.
> If you want to write truly compatibel C code, your lines should be
within 80
> characters
> AFTER trigraph expansion. If you don't intend to port to older
mainframes, I
> wouldn't know why you should bother.
Questions 1 and 2 were just to calm my curiosities.
If you know an simple code example, I will be grateful
to have a look at it.
K&R II, Section A12.1:
... In order to enable programs to be represented in
the reduced set, all occurences of the following trigraphs
sequences are replaced by the corresponding single character.
**This replacement occur before any other processing.**
...
So, in the following program:
#include <stdio.h>
int
main ( void )
{
char a[] = "??(abc??)"; /* Should it be: char a??(??) = "..."; ?
*/
puts ( a );
exit ( 0 );
}
the output is: ??(abc??).
Should if not be [abc] ?
Thanks
Vijay Kumar R Zanvar
---------------------------------------------------
In article <bo7gjj$1a21i0$1@ID-203837.news.uni-berlin.de>
Vijay Kumar R Zanvar <vijaykumar.rz@globaledgesoft.com> writes:
>... in the following program:
[snippage]
> char a[] = "??(abc??)"; /* Should it be: char a??(??) = "..."; ? */
> puts ( a );
>the output is: ??(abc??).
>Should if not be [abc] ?
It should be, and it is here:
% cc -ansi -pedantic -W -Wall -O -o t t.c
t.c: warning: 4 trigraph(s) encountered
% ./t
[abc]
%
You may use the trigraph syntax as shown in the comment if you
wish, too.
Note that without the "-ansi" switch, gcc stops recognizing
trigraphs:
% cc -pedantic -W -Wall -O -o t t.c
% ./t
??(abc??)
%
I have never found anyone who *likes* trigraphs (even on IBM systems
with their wacky code page problems :-) ), and most people never seem
to use them. As a result, at least this one compiler (gcc) pretends
they do not exist by default; you must explicitly (-trigraphs) or
implicitly (-ansi) enable them. (The compiler runs more slowly when
they are turned on, too, although with today's multi-gigahertz CPUs,
who really notices?)
--
In-Real-Life: Chris Torek, Wind River Systems