Difference between revisions of "C programming language"

From Computer History Wiki
Jump to: navigation, search
(hello world: Hello world in ancient C.)
(hello world: New B.)
Line 42: Line 42:
 
</pre>
 
</pre>
  
C was derived[http://cm.bell-labs.com/cm/cs/who/dmr/chist.html] from an earlier language called [[B]]
+
C was derived[http://cm.bell-labs.com/cm/cs/who/dmr/chist.html] from an earlier language called [[B]].  There was an intermediary language called NB, or New B.
  
 
A number of object-oriented languages have been influenced by C, including
 
A number of object-oriented languages have been influenced by C, including

Revision as of 08:16, 19 August 2021

The C language.....

Dialects

There are two popular dialects, the original was K&R C, which spread with the original C compiler, and pcc, the portable C compiler. Later there was a ANSI standard to the C language, and it's usually refered to as just ANSI C.

hello world

Ancient

char *hello "hello"; /* No = for initialization. */

main (argc, argv)
int argc;               /* Parameter declarations as in K&R. */
char **argv;
{
        char *world;    /* Auto variables can't be initialized. */
        world = "world";
        cprint ("%s %s\n", hello, world);       /* No stdio yet. */
}

K&R

#include <stdio.h>
main(argc,argv)
int argc;
char **argv;
{
        printf("Hello World\n");
        exit (0);
}

ANSI C

#include <stdio.h>
int main(int argc, char *argv[])
{
        printf("Hello World\n");
        return 0;
}

C was derived[1] from an earlier language called B. There was an intermediary language called NB, or New B.

A number of object-oriented languages have been influenced by C, including Objective-C, C++, D, Vala.

See also