473,898 Members | 4,144 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trigraphs & entry

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?

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.

Nov 13 '05 #1
14 8469
On Tue, 4 Nov 2003 09:52:03 +0530, "Vijay Kumar R Zanvar"
<vi***********@ 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
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Nov 13 '05 #2

"Vijay Kumar R Zanvar" <vi***********@ globaledgesoft. com> wrote in message
news:bo******** *****@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.

Nov 13 '05 #3

"pzinnc296" <pz*******@roge rs.com> wrote in message
news:SU******** ************@tw ister01.bloor.i s.net.cable.rog ers.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] ?


Nov 13 '05 #4
In article <bo************ *@ID-203837.news.uni-berlin.de>
Vijay Kumar R Zanvar <vi***********@ 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
Salt Lake City, UT, USA (4039.22'N, 11150.29'W) +1 801 277 2603
email: forget about it http://67.40.109.61/torek/index.html (for the moment)
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 13 '05 #5

"Chris Torek" <no****@elf.eng .bsdi.com> wrote in message
news:bo******** **@elf.eng.bsdi .com...
[..]
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]
%


[..]

Thanks. It was almost like a climax! :-) Now I understood.
Nov 13 '05 #6
Chris Torek wrote:
....
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.


True, if one uses US keyboards. But think what would be your opinion if
you should write a C program using a variety of keyboards including, for
example, the italian one where there is no curly or square bracket at all !

I admit that I do not like *to see* trigraphs in C code. But I *like*
them very much if I have to write C code using a keyboard missing some
keys crucial for C. Luckly, who put them in the standard was aware of
the problems of a multicultural world.
Giorgio Pastore

Nov 13 '05 #7
On 3 Nov 2003 23:45:20 -0700, Chris Torek <no****@elf.eng .bsdi.com> wrote:
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (4039.22'N, 11150.29'W) +1 801 277 2603
email: forget about it http://67.40.109.61/torek/index.html (for the moment)


Chris, how's work going on the "C for Smarties (work in progress)"
(<http://67.40.109.61/torek/c/index.html>)? The webpage says it was last updated
on 10 Jun 2001. Will it be out "real soon now"? :)
Nov 13 '05 #8
On Tue, 04 Nov 2003 09:56:02 +0100, Giorgio Pastore wrote:
Chris Torek wrote:
...
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.


True, if one uses US keyboards. But think what would be your opinion if
you should write a C program using a variety of keyboards including, for
example, the italian one where there is no curly or square bracket at all !


Just curious, but is this true of current italian keyboards, or
just old ones?

I, for example, use a german keyboard. All of the required characters
are there, but many of them require using the "Alt Gr" key, from
which I infer that older german keyboards simply did not have them.

As a bonus, the presence of the Alt Gr key also lets me type other
characters that are difficult to find on a standard US keyboard
¬¹²³¼½¸ ⅛£¤⅜⅝ ™±°¿¸¯ `×÷˙¦ΩŁ ®Ŧ¥↑ıØ ¨Æ§ÐªŊĦ Ł˝©`'º

Nov 13 '05 #9
"Vijay Kumar R Zanvar" <vi***********@ globaledgesoft. com> wrote in message news:<bo******* ******@ID-203837.news.uni-berlin.de>...

<snip>
2. What `entry' keyword was used for?

[off-topic]

The entry keyword was intended to provide subroutines with more than
one point of entry. That way, you could write one block of code and
have it `stand in for' different subroutines, because different calls
would deposit you to different places within the code.

The problem with this is obvious: It reduces subroutine calls to
gotos, and it makes it difficult to predict exactly where the next
step of the program would take you. It /could/ be used in structured
code, but only with care. Besides that, it really offers nothing real
subroutines don't.

The concept was borrowed from FORTRAN and was part of very early
designs of C. Apparently, some compiler designers did implement it,
but I've never seen an implementation that actually used the entry
keyword.

Really, it isn't a big loss. The concept of one subroutine with
multiple entry points was on its way out even before C was new, and it
was wise of the standards makers to ignore such a half-baked idea.

[/off-topic]
<snip>
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6477
by: yee young han | last post by:
I need a fast data structure and algorithm like below condition. (1) this data structure contain only 10,000 data entry. (2) data structure's one entry is like below typedef struct _DataEntry_ { char szInput; char szOutput; int iSum;
39
496
by: Daniel Rudy | last post by:
What exactly are trigraphs, and why are they undesireable? -- Daniel Rudy Email address has been base64 encoded to reduce spam Decode email address using b64decode or uudecode -m Why geeks like computers: look chat date touch grep make unzip
6
10063
by: Geoffrey S. Knauth | last post by:
It's been a while since I programmed in C++, and the language sure has changed. Usually I can figure out why something no longer compiles, but this time I'm stumped. A friend has a problem he hoped I could solve, and I couldn't. Some code he's using, written in 1999, that compiled fine in 1999, no longer does in 2006 with g++ 4. This little bit of code: SimS::SimS (ostream &s) {
7
4641
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get BeautifulSoup to clean those up? There are various parsing options related to "&" handling, but none of them seem to do quite the right thing. If I write the BeautifulSoup parse tree back out with "prettify", the loose "&" is still in there. So...
0
9994
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9842
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11265
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10956
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8036
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5882
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4298
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.