473,883 Members | 1,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why still use C?

no this is no trollposting and please don't get it wrong but iam very
curious why people still use C instead of other languages especially C++.

i heard people say C++ is slower than C but i can't believe that. in pieces
of the application where speed really matters you can still use "normal"
functions or even static methods which is basically the same.

in C there arent the simplest things present like constants, each struct and
enum have to be prefixed with "struct" and "enum". iam sure there is much
more.

i don't get it why people program in C and faking OOP features(functi on
pointers in structs..) instead of using C++. are they simply masochists or
is there a logical reason?

i feel C has to benefit against C++.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05
687 23866
"cody" <do************ *********@gmx.d e> wrote:
<snip>

return 1 //* <-- the c version misses a semicolon here,
additionally //* will imho produce no valid comment in c.

-1 + 1; /* 0 in C99, 1 in C++ */
}


In C90: //* will be tokenized as
/ (division operator) followed by
/* (comment start)

In C99: //* will be tokenized as
// (single line comment start)

Thus, after stripping the comments and newlines

return 1 //*
-1 + 1; /* ... */

in C90 results in:

return 1 /

but in C99 results in:

return 1 -1 + 1;

Regards
--
Irrwahn
(ir*******@free net.de)
Nov 13 '05 #251
"cody" <do************ *********@gmx.d e> wrote:
<snip>
What is a sig-monster?


I am a <insert your favourite attribute here> one. Groooarrrchrr.
--
Three is no spimle sbtsuuttie for cearful, cercrot,
wtlirtew-len Esglinh. Tehre is no slveir beullt.

- Rhacrid Hfiaehlted in comp.programmin g, 2003-09-25
Nov 13 '05 #252

"Brian Inglis" <Br**********@S ystematicSw.ab. ca> wrote in message
news:41******** *************** *********@4ax.c om...
An integer character constant is a sequence of one or more
multibyte characters enclosed in single-quotes, as in 'x'.

Was is the same in other versions of C besides C99?


As far back as K&R1 -- common C idiom was 'ab' (16 bit) or 'abcd'
(32 bit) to handle packed chars -- undefined behaviour as of C89
-- but still allowed and works?


Not undefined, implementation-defined in both C89 and C99.

Dennis
Nov 13 '05 #253
cody wrote:
> int i = sizeof (int);
> // int j = sizeof int; // invalid in both C and C++
> int k = sizeof i;
> int l = sizeof (i);
>
> The form of sizeof that gets a type as parameter has to use
> parantheses, while the sizeof that gets non-expressions as parameter do
> not need
them.

Wrong. In your example, i is an unary-expression, not a non-expression.


I don't know why i wrote non-expression. My example clearly showed how to
use sizeof:


It's improving, but still not quite there. You should really use size_t
rather than int here, and note that // comments are valid in C99 but /not/
in C90, and most of the world is still using C90, so they are best avoided,
at least for now.

The form of sizeof that gets a type (NON-EXPRESSION) as parameter has to
use parantheses,
while the sizeof that gets expressions (NON-TYPES) as parameter do not
need them.

Is it now correctly stated?


Why make up a description? Why not just say:

3.3.3.4 The sizeof operator

Constraints

The sizeof operator shall not be applied to an expression that has
function type or an incomplete type, to the parenthesized name of such
a type, or to an lvalue that designates a bit-field object.

Semantics

The sizeof operator yields the size (in bytes) of its operand,
which may be an expression or the parenthesized name of a type. The
size is determined from the type of the operand, which is not itself
evaluated. The result is an integer constant.

--
Richard Heathfield : bi****@eton.pow ernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #254
On Thu, 16 Oct 2003 23:57:20 +0200
"cody" <do************ *********@gmx.d e> wrote:
"Mark Gordon" <sp******@fla sh-gordon.me.uk> schrieb im Newsbeitrag
news:2003101523 2209.128f9a60.s p******@flash-gordon.me.uk...
On Wed, 15 Oct 2003 22:17:35 +0200
"cody" <do************ *********@gmx.d e> wrote:

Please don't trim the attributions since it prevents people from
seeing who said what.
> int test(int size)
> {
> int *new = malloc(size); /* two non-C++isms in this line
> */ return 1 //*
> -1 + 1; /* 0 in C99, 1 in C++ */
> }

is the missing semicolon at the end of a block allowed in C?
A semicolon is required to terminate every C statement, however in
C99 there is no missing semicolon in the above.

HINT: C99 added a form of // commenting.

int test(int size)
{
int *new = malloc(size); /* two non-C++isms in this line */

return 1 //* <-- the c version misses a semicolon

^^ This starts a comment, the * is just a commented
out character. here,
additionally //* will imho produce no valid comment in c.
In C99, once it has seen the // everything after on the line is
considered a comment.

Copied from section 6.4 of a copy of n897.pdf...

// comments were added for C9X ....

In certain unusual situations, code could have different semantics
for C90 and C9X. for example

a = b //*divisor:*/ c
+ d;

In C90 this was equivalent to

a = b c + d;

but in C9X it is equivalent to

a = b + d;

As you can see from the above in C99, //* is treated as a // style
comment the first character of which happens to be a * and the // style
comment ends at the end of the line. So for the example at the top in
C99, which is what it refers to, the first comment starts with a // and
ends at the end of the line, then the next line starts off not being a
comment until the /* ... */ style comment which is AFTER the semi-colon.

If neither myself nor whoever posted the example had referred to C99
then you would have been correct in thinking that there was a missing
semicolon.
-1 + 1; /* 0 in C99, 1 in C++ */ ^^^^^^^ not commented out because // comment ended at end
of last line. }


I'm sure that Dan or one of the others who know the C standards better
than me would have corrected me if I was wrong. They have certainly
corrected me in the past when I made mistakes and I definitely want them
to continue to point out anything I get wrong.
--
Mark Gordon
Paid to be a Geek & a Senior Software Developer
Although my email address says spamtrap, it is real and I read it.
Nov 13 '05 #255
cody wrote:
What is a sig-monster?


http://www.google.com/search?q=sig-monster

/Sven ;)

PS: No offence intended, but you should really start using stuff like
books and search engines. It makes your life far easier!

--
Remove "-usenet" from the email address to contact me.
Nov 13 '05 #256
Mark Gordon <sp******@fla sh-gordon.me.uk> wrote:
<snip>

In certain unusual situations, code could have different semantics
for C90 and C9X. for example

a = b //*divisor:*/ c
+ d;

In C90 this was equivalent to

a = b c + d; ITYM:
a = b / c + d;

I had a spare slash, so I thought I just place it in the gap :)

but in C9X it is equivalent to

a = b + d;

<snip>

Regards
--
Irrwahn
(ir*******@free net.de)
Nov 13 '05 #257
"cody" <do************ *********@gmx.d e> wrote in message news:<bm******* *****@ID-176797.news.uni-berlin.de>...
"Mark Gordon" <sp******@fla sh-gordon.me.uk> schrieb im Newsbeitrag
news:2003101523 2209.128f9a60.s p******@flash-gordon.me.uk...

....
HINT: C99 added a form of // commenting.

int test(int size)
{
int *new = malloc(size); /* two non-C++isms in this line */

return 1 //* <-- the c version misses a semicolon here,
additionally //* will imho produce no valid comment in c.

-1 + 1; /* 0 in C99, 1 in C++ */
}


You would be correct in C89, but not in C99 (see section 6.4.9). Did
you think that Mark Gordon was lying with his hint? Did you even
bother to check?

Both C99 and C++ recognise // comments, and the rules for handling
them are similar. In both languages, after comments have been removed,
your example code would look like:

int test(int size)
{
int *new = malloc(size);

return 1
additionally

-1 + 1;
}
In both languages, the word "additional ly" is a syntax error, so I
suspect it was typo, or maybe an artifact of your lines getting
wrapped at the wrong location. In both languages, the absence of a
#include of a standard header file means that there's no prototype in
scope for your call to malloc(), which presents a problem in either
language (though the nature of the problem is slightly different in
each case).

Assuming that you add a line which says

#include <stdlib.h>

and move the "additional ly" so that it's inside a comment, the code
still has a syntax error as far as C++ is concerned, because 'new' is
a keyword. However, both languages see a 'return' statement that is
correctly terminated by a ';', and the value returned would be 1, if
it weren't for the other problems.
Nov 13 '05 #258
On Fri, 17 Oct 2003 11:42:51 +0200
Irrwahn Grausewitz <ir*******@free net.de> wrote:
Mark Gordon <sp******@fla sh-gordon.me.uk> wrote:
<snip>

In certain unusual situations, code could have different semantics
for C90 and C9X. for example

a = b //*divisor:*/ c
+ d;

In C90 this was equivalent to

a = b c + d;

ITYM:
a = b / c + d;

I had a spare slash, so I thought I just place it in the gap :)


Damn. I knew I should have bought more slashes when I went shopping last
weekend. :-)

Also proves my point that I would have been corrected if I had made a
mist ook.
--
Mark Gordon
Paid to be a Geek & a Senior Software Developer
Although my email address says spamtrap, it is real and I read it.
Nov 13 '05 #259
thp
In comp.std.c j <ja**********@b ellsouth.net> wrote:
[...]
+ I don't know why people mold terms to fit things how they would like to see
+ them. C++ is not a superset, period. ``strict superset'' throw it out of the
+ window. When something is a ``superset'' of something else, that something else is
+ considered to be a ``subset''.
+ Now inorder for C to be a subset of C++, you would be able to compile _any_
+ C program with a C++ compiler. This can't be done, because C is not a subset
+ of C++, and that is because C++ is not a superset of C. It is a
+ ``derivative'' of C. Nothing more and nothing less.

C and C++ have a relatively large semantic intersection, i.e., set of
programs to which C and C++ attach identical behavior. It's my
impession that the intersecton includes the majority of actual C
programs.

Tom Payne

Nov 13 '05 #260

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

Similar topics

3
11266
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL) on the server because of that. Our site will have an SSL certificate next week, so I would like to use AIM instead of SIM, however, I don't know how to send data via POST over https and recieve data from the Authorize.net server over an https...
2
5865
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues to execute the code until the browser send his reply to the header instruction. So an exit(); after each redirection won't hurt at all
3
23053
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which field is completed.
0
8508
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. 354 roberto@ausone:Build/php-4.3.2> ldd /opt/php4/bin/php libsablot.so.0 => /usr/local/lib/libsablot.so.0 libstdc++.so.5 => /usr/local/lib/libstdc++.so.5 libm.so.1 => /usr/lib/libm.so.1
1
8621
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the column below. The viewer can select states from the drop down lists above the other two columns as well. If the viewer selects only one, only one column fills. If the viewer selects two states, two columns fill. Etc. I could, if appropriate, have...
4
18317
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the user comes back to a page where he had a submitted POST data the browser keeps telling that the data has expired and asks if repost. How to avoid that? I tried registering all POST and GET vars as SESSION vars but
1
6890
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url http://www.mis.gla.ac.uk/biquery/training/ but each of the courses held have maximum of 8 people that could be
2
31461
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value to :parameter I dont like the idea of making the SQL statement on the fly without binding parameters as I dont want a highly polluted SQL cache.
3
23617
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the results of the picture half the size. The PHP I have installed support 1.62 or higher. And all I would like to do is take and image and make it fit a 3x3. Any suggestions to where I should read or look would be appreciated.
0
9934
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
9789
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
11137
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
10736
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...
0
10409
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
9570
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
7120
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();...
2
4214
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3230
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.