473,900 Members | 4,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Some general questions about C and good practice

Hey! Some questions about C that have been bugging me for a while...

1) Is inline a valid C keyword or not? I was kind of surprised of not
finding it in C, to be honest. My "The C Programming Language" book
doesn't mention it.

2) I understand that C doesn't care about whitespace that much, but why
did they make it impossible to use the minus ('-') char in variable
names? I now have to incorrectly name my "hi-score" variable "hiscore".
:(

3) Is using "const" in C considered good practice? I have had little
need to do so so far thanks to #define.

4) I kind of hate C-like comments. I use C++ comments mostly in my C
programs. Is this evil?

5) I feel kind of naked without bool, but I understand that by the way
computers work, an int holding only 0 or 1 makes the most sense. Or
something. Does it?

PS: I started with C++ and went "back" to C after several years of not
getting anything done thanks to the damn OOP. In C, I'm all creative
again! ^__^

--
http://www.kimmoa.se/

Sep 11 '06
66 3767
Martin Ambuhl wrote:
Yes, but any well-written C is supposed to compile as a C++ program.
That's what I meant. Sorry.

That's garbage. Yes, I know that BS has that printed in various of his
C++-pushing books, but it is a lie. When BS says "any well-written C
program" he means "any C program that obeys the style that I, BS, have
laid down and is the same as I, BS, have laid down for C++." The fact
is that his version of "well-written C program" involves many things
that are at least stylistic blunders in C. If you want to quote BS
about C++, feel free to do so in come appropriate forum, which
comp.lang.c is not, but almost everything he says about C amounts to
self-promotion and C++ advocacy. He is no authority on "well-written C".
Hmm... "BS" sounds like something else...

Why can't I quote Bjarne about C++ here? I'm not saying that it's the
Truth, or that I even agree with it. It's just a quote. I actually got
the feeling that Bjarne in fact likes C.

--
http://www.kimmoa.se/

Sep 13 '06 #31
Keith Thompson wrote:
>
.... snip ...
>
The only exception is when you have some real requirement to write
code that will compile as either C or C++. In real life, such a
requirement is almost vanishingly rare.
Such as when you are selling cloaked C source that is likely to be
compiled by idiots who don't know how to specify a C compilation,
and you don't want to waste your time holding their quivering
little hands.

--
"I was born lazy. I am no lazier now than I was forty years
ago, but that is because I reached the limit forty years ago.
You can't go beyond possibility." -- Mark Twain

--
Posted via a free Usenet account from http://www.teranews.com

Sep 13 '06 #32
KimmoA said:
Keith Thompson wrote:
>C and C++ are two different languages.

Yes, but any well-written C is supposed to compile as a C++ program.
Whoever told you that doesn't know what they're talking about.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 13 '06 #33
KimmoA said:
Martin Ambuhl wrote:
>[Bjarne Stroustrup] is no authority on "well-written C".

Hmm... "BS" sounds like something else...

Why can't I quote Bjarne about C++ here?
But you did, so obviously you can. But it's not a good idea; this is
comp.lang.c, not comp.lang.c++. If you want to talk about C++, it might be
better to do so in comp.lang.c++, yes?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Sep 13 '06 #34
Richard Heathfield wrote:
Why can't I quote Bjarne about C++ here?

But you did, so obviously you can.
"Can't" as in... "can't"! :)
this is comp.lang.c, not comp.lang.c++. If you want to talk about C++, it might
be better to do so in comp.lang.c++, yes?
Yes, but I'm a C coder. The C++ reference(s) seemed relevant in the
discussion.

--
http://www.kimmoa.se/

Sep 13 '06 #35
KimmoA wrote:
Martin Ambuhl wrote:
>.... If you want to quote BS
about C++, feel free to do so in come appropriate forum, which
comp.lang.c is not,
Why can't I quote Bjarne about C++ here? I'm not saying that it's the
Truth, or that I even agree with it. It's just a quote. I actually got
the feeling that Bjarne in fact likes C.
Who said you can't. I certainly didn't. I wrote that comp.lang.c was
not an appropriate newsgroup for posting about some other language. We
don't give a rat's ass about C++ or about what BS has to say about it.
If you insist on posting about C++ in comp.lang.c, or about Lisp in a
COBOL newsgroup, or about Forth in a Fortran newsgroup, you can do that
too. But you are also free to join all the other off-topic toads in the
killfile.
Sep 13 '06 #36
"KimmoA" <ki****@gmail.c omwrote:
Keith Thompson wrote:
C and C++ are two different languages.

Yes, but any well-written C is supposed to compile as a C++ program.
Then C++ has failed fundamentally, because most well-written C programs
of any reasonable complexity do not compile as C++.

Richard
Sep 13 '06 #37
"KimmoA" <ki****@gmail.c omwrote:
In "The C++ Programming Language" (Special Edition), on the bottom of
page 13 (chapter 1, section 1.5), he (Bjarne) says:

"However, good C programs tend to be C++ programs. For example, every
program in [The C Programming Language book], is a C++ program."

This must be where I got it from. Sure... I misquoted him, but it's
been a while since I read it. You can't say that it's entirely false,
though!
I not only _can_ say that it's entirely false, I _do_ say that it's
entirely false, and if Bjarne really wrote that, more than a little
dishonest of him.

Richard
Sep 13 '06 #38
Richard Bos wrote:
if Bjarne really wrote that
I hope you're not suspecting that I'm making this shit up. Becuase I'm
not.

--
http://www.kimmoa.se/

Sep 13 '06 #39
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
"KimmoA" <ki****@gmail.c omwrote:
In "The C++ Programming Language" (Special Edition), on the bottom of
page 13 (chapter 1, section 1.5), he (Bjarne) says:

"However, good C programs tend to be C++ programs. For example, every
program in [The C Programming Language book], is a C++ program."

This must be where I got it from. Sure... I misquoted him, but it's
been a while since I read it. You can't say that it's entirely false,
though!

I not only _can_ say that it's entirely false, I _do_ say that it's
entirely false, and if Bjarne really wrote that, more than a little
dishonest of him.
It's also entirely possible that at the time he wrote that, it was
true -- C++ did evolve out of C, after all. It seems to me that
"dishonest" involves more intent than I think can be accurately
ascribed here.

(On the other hand, the larger point, that C and C++ are stylistically
very different, and good C and good C++ do not tend to resemble each
other, remains valid despite what Dr Stroustrup may have written.)

Charlton

Sep 13 '06 #40

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

Similar topics

1
2619
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for topics to include in a course on object-orientation that I'm going to conduct. (I will later summarize all the replies and discussion, for the
193
9721
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I speak only of features in the spirit of C; something like object-orientation, though a nice feature, does not belong in C. Something like being able to #define a #define would be very handy, though, e.g: #define DECLARE_FOO(bar) #define...
19
2216
by: pamelafluente | last post by:
Hi Guys, I am trying to include my little script in my html report. I have done an external JS file which contains it. If you remember, you have helped me to detect if the asp page was present by using ajax. If not present is gracefully stay silent. The problem is now that when the JS is not present (and it can be) MSIE gives a lot of errors and one has to kill it.
0
9997
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9845
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
11276
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...
0
10866
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10976
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
9671
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 project—planning, coding, testing, and deployment—without 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...
0
7204
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5891
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...
1
4721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.