TIP: Click on subject to list as thread! ANSI
echo: apple
to: comp.sys.apple2,comp.sys.apple2.pro
from: pausch
date: 2008-04-17 16:15:34
subject: Re: Aztec C: C ++??

In article ,
David Empson  wrote:

>I'd have to hunt through old documentation to find the other major
>differences as I've been using ANSI C so long I'm somewhat hazy on what
>else was missing from the language in earlier versions.

Some other differences were:

In ANSI C, struct's can be passed by value to functions and a function
can have a struct as its return value.  In K&R C you could only do that
with pointers to struct's.  And I think software like ANSI2KNR would
have a quite hard time handling THAT case..... memory would have to
be allocated for these struct parameters and automatically deallocated
at the proper place.... I think you get the idea...

In ANSI C, float arithmetic is allowed - in K&R C, real arithmetic always
had to be performed as double arithmetic.

A number of predefined macros was added to ANSI C.

A number of new library functions was added to ANSI C.  And in ANSI C,
the standard library became part of the language - that was not the
case with K&R C.

In ANSI C, calling a pointer to a function could be performed with
the regular function call syntax.  One example:

    int (*fptr)(int,int);

......

    fptr = some_function;

......

In ANSI C, this is legal while in K&R C it's a syntax error:

    fptr(23,45);

In K&R C you *had* to call the function pointer like this:

    (*fptr)(23,45);

That was legal too in ANSI C - even for a regular function!  Thus, in
ANSI C you can also do:

    (*printf)("Hello, world\n");

would would be illegal in K&R C.  In ANSI C you can even do:

    (*****************************************printf)("Hello, world\n");

and it works !!!!


In ANSI C you can do "string pasting", e.g.:

    char *s = "First part of string, "   "second part of string";

In K&R C you had to do it like this:

    char *s = "First part of string, second part of string";

or like this:

    char *s = "First part of string, \
second part of string";

which looks a bit ugly....


String pasting is particularly handy when you have strings defined
as macros - you can then paste them together by just writing the
macro names one after another.

-- 
----------------------------------------------------------------
Paul Schlyter,  Grev Turegatan 40,  SE-114 38 Stockholm,  SWEDEN
e-mail:  pausch at stjarnhimlen dot se
WWW:     http://stjarnhimlen.se/
--- SBBSecho 2.12-Win32
* Origin: Derby City BBS - Louisville, KY - derbycitybbs.com (1:2320/100)
SEEN-BY: 10/1 3 14/300 34/999 90/1 106/1 120/228 123/500 134/10 140/1 222/2
SEEN-BY: 226/0 236/150 249/303 261/20 38 100 1404 1406 1410 1418 266/1413
SEEN-BY: 280/1027 320/119 393/11 396/45 633/260 267 712/848 800/432 801/161
SEEN-BY: 801/189 2222/700 2320/100 105 200 2905/0
@PATH: 2320/100 261/38 633/260 267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.