C

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

C ( )

C ( : "" - C ) ,
1972. . , Bell
Laboratories UNIX.

[]

1.1 K&R C

1.2 ANSI C ISO C

1.3

1.4 ()

4 C

6.1

6.2

7.1

7.2

7.3

7.4

10

11

12

13

14

[]

UNIX , ,
,
. UNIX-
,
, , .
, .
C- ,
. , x++
INC. , UNIX-a.
,
UNIX. .
,
.
, C++, -.
[]K&R

(. Brian Kernighan) (. Dennis Ritchie) 1978.


C (. The C Programming Language). ,
K&R, .
- K&R . 89 ANSI C
. (American National Standard Institute (ANSI))
je 1983 , X3J11, . 1989
ANSI X3.159-1989 Programming Language C. - ANSI C, ,
89. ANSI C 1990.
(ISO)}- ISO/IEC 9899:1990.
90. C89 C90 .
[]ANSI

C ISO C

70 80, -
mainframe , , IBM PC,
. 1999. ISO/IEC 9899:1999.
99. 99 ,
:

inline

, long long int, boolean , complex


, snprintf

//

IEEE 754 -

.
.

[]

GCC 99 . ,

++, .
C99, GCC ;
[1]
.
Sun Microsystems, Sun Studio ( )
[2]
99 .
[]

()

__STDC_VERSION__ 199901L
C99 . __STDC__ C90, __STDC_VERSION__
90 99 . :
#if __STDC_VERSION__ >= 199901L
/* "inline" */
#else
# define inline /* */
#endif
[]
je C UNIX DEC- PDP11. , C UNIX- C-.
.
, ,
Windows- UNIX-,
. , .
C- ,
C-.
[]

C- . .
(. main), ,
. ,
.

.
.
, .
.

main.
( ). main,
.
C .
.
, .
[]C

C . C ,
(), , ( ), ,
, , ,
()...

(typecast)

(double)n

cast(. );

n double
()

f()

[]

n[10]

->

s->x

s.x

+ []

+x

- []

-x

* []

*x

& []

&x

; x

++ []

++x

++ []

x++

-- []

--x

-- []

x--

sizeof

sizeof (t1)

t1

sizeof

sizeof e

x + y

x y

e
+ []

- []

x - y

x y

* []

x * y

x y

x / y

x y

x % y

x/y

>>

x >> y

x << y

x< y

- ;1 x< y; 0

x> y

- ;1 x> y; 0

x<= y

- ;1

x >= y

- ;1

x == y

- ;1 x

x != y

- ;1 x

<<

<

>

<=
x <= y; 0
>=
x >= y; 0
==
y; 0
!=

y; 0
& []
| []
^ []

x & y
y

AND x y
OR x y

x ^ y

XOR ( OR)

~x

&&

x && y

AND x y ( 0

x y

1)
||

| y

OR x y ( 0

1)
!

!x

NOT ( ) x

( 0 1)
?:

x ? e1 : e2

( ); e2

.; e1 x

x = y

; x,

x += y

x y ( x)

-=

x -= y

x y ( x)

*=

x *= y

x y ( x)

/=

x /= y

x y ( x)

%=

x %= y

x/y ( x)

>>=

x >>= y

x, x


+=

( x)
<<=

x <<= y

x, x

( x)
&=

x &= y

x AND y ( x)

|=

= y

^=

x ^= y

x XOR y ( x)

e1,e2

e2 ( 1)

x OR y ( x)

() [] -> . ++ --

! ~ ++ -- + - * & (type) sizeof

* / %

+ -

<< >>

< <= > >=

== !=

AND

&

XOR

OR

AND

OR

?:

= += -= *= /= %= >>= <<= &= ^= |=


&&

||

[]
.
main()

{
}
Hello World , C.
. Zdravo svete.
#include <stdio.h>
/*
*/
int main(void)
/* main */
{
printf("Zdravo svete\n"); /* printf
stdio.h, */
return 0;
/* */
}
. main -
main .
#include <stdio.h>
- . /* */
. main printf ,
. printf
, :
#include <stdio.h>
int main(void)
{
printf("Dobar ");
printf("dan.");
printf("\n");
return 0;
}
, \n.
, return 0, main .
[]

,
main. ,
return exit. ,
C , . .
.
[]
( ,
,

), .

, .
: if...else switch.
if...else ... . :
if ( n < 10 ) {
printf( "n 10" );
} else {
printf( "n 10" );
}
n 10, ("n
10"). , n 10, .
switch , .
.
:
switch ( n ) {
case 1: printf( "n " );
break;
case 2: printf( "n " );
break;
default: printf( "n " );
}
[]
.
- ,
. ,
.
. , . C
:

while

do...while

for

while :
while (izraz)
iskaz;
. ,
. ,
.
do...while :

do
iskaz;
while (izraz);
while for ,
, do...while ,
.
for :
for(izraz1;izraz2;izraz3)
iskaz;
. 1 3
, 2 . ,
. for :
izraz1;
while (izraz2){
iskaz;
izraz3;
}
:
for(;;) {
...
}
. break return.
[]

: .
C, :

[]

.
:

( int)

(char)

( float -
double -
)

, , :

( short)

(long)

, :

( signed, )

( unsigned)

, ,
, . signed unsigned
. , x
,
; :
unsigned long int x;
int .
.
<limits.h> <float.h> .
[]
: .
, .
. -
, , ,
. ( 90 .) ,
malloc ,
.
calloc.
() free. .
,
. 0.
:
int niz[40]; /* 40 */
int x;
x = niz[0]; /* x */
,
, .
C-a . C-
. x[i] x ;
(i+1)-
x, x ( x[0]) .

, x[i] *(x+i).
, x+i x
i, i .
sizeof.
.
.
i n.
x[i]=1;
*(x+i)=1;
*(i+x)=1;
i[x]=1; /* , : i[x] *(i+x)*/
, .
( ),
. , ,
. ( memcpy, .)
[]

struct,
.
(, ).
,
+, -, *, /, %, &, &&,|, ||, <, >, <<, >>, !, != ?:, +=, -=, ++, -, *=, >>=, . (=) , ,
. , : -
(.) -
(
- ->).
, , ,
sizeof, .
, , :
/* Radnik */
struct Radnik {
short int godine; /* ,

short
*/
char pol; /* ,
m z */
char str_sprema[30], ime_i_prezime[40]; /*

,
*/
};
/* r struct Radnik */
struct Radnik r;
/* */
r.godine = 44;
r.pol = 'm';
strcpy( r.str_sprema, "Srednja strucna sprema" );
strcpy( r.ime_i_prezime, "Petar Petrovic" );
/* */
printf( "%s \"%s\" ima %d godina, i ima strucnu spremu \"%s\"",
r.pol=='m'?"Radnik":"Radnica", r.ime_i_prezime, r.godine, r.str_sprema );
[]

: .
.
&. & . ,
register .
(.
).
. ,
( ), , .
. void.
C (*), ,
. *
. ,
. n,
np n :
int n = 2;
/* n 2*/
int *np;
/* np
*/
np = &n;
/* n np */
printf( "%d", *np ); /* n
np */
[]


. (,
) :


.
,
,
. ,
, ( 89 90
) ,
.
[]

, . ,
. C90 :

auto

extern

sizeof

break

float

static

case

for

struct

char

goto

switch

const

if

typedef

continue

int

union

default

long

unsigned

do

register

void

double

return

volatile

else

short

while

enum

signed

[3]

C99 :

inline

_Bool

restrict

_Complex

_Imaginary

() :

ada

far

near

asm

fortran

pascal

entry

huge

_
.
[]
.
-, . (header file),
, , ,
.
, ,
(linked) .
, ISO ANSI C
. ,
:
<assert.h>

<ctype.h>

<errno.h>

<float.h>

<limits.h>

<locale.h>

<math.h>

<setjmp.h>

<signal.h>

<stdarg.h>

<stddef.h>

<stdio.h>

<stdlib.h>

<string.h>

<time.h>

C99 :
<complex.h>

<fenv.h>

<inttypes.h>

<stdbool.h>

<stdint.h>

<tgmath.h>

: #include<>
UNIX, .
POSIX Single UNIX Specification.
-, .
- .
[]
C-a
. , , ,
C-:

C++

Java

PHP

C# (C Sharp)

JavaScript

C ,
,
. C
,
( ++, --,
BEGIN END .), .
[]

1.

^ Status of C99 features in GCC. Free Software Foundation, Inc.. 22. 11. 2007. 9. 1. 2008.

2.

^ Sun Studio 12: C Compiler 5.9 Readme. Sun Microsystems, Inc.. 31. 5. 2007. 9. 1. 2008.

3.

^ C99, sun.com

[]

(C99 1, 2 3) ((en))

C- ((en))

comp.lang.c ((en))

C- - ((en))

[]

, , 1978, C, Prentice Hall. ISBN 0-13-110163-3

, 1994, UNIX , SAMS Publishing. ISBN 86-7991-043-0

: , , 1996,

, : C/C++ , , 2003,

You might also like