:
[<__>] [<>] <> <1>[=<1>], <2>[=<2>],, <N>[=<N>];
<__> ( ) : auto, register, static, extern.
<> - : const, volatile .
const , ( ) , . volatile , - , , , ( ).
:
int i, j=10;
const float pi=3.14; // pi
extern double x; // ,
// .
unsigned char C1=A, C2=10, C3;
.
, .
, :
- .
. . : , , , , . :
- int ( ), MS DOS 2 , Win32 4 , : 1245, 6, 175, 5, 1425;
- long 4 , , int ( MS DOS), l (L), : 12l, 14567L, 125234 ( MS DOS);
- unsigned int unsigned long, u (U), 105u (unsigned int), 105ul(unsigned long).
, , : -1000, -200l.
. , , . :
- ( ) 1234, 378l, 346;
|
|
- , 2 0x ( 0X), : 0..9, A (a), B (b), , F (f), 0x10, 0x10acd, 0XFFFF;
- , 0, : 0..7, 010, 070, 01237;
- .
, . . .
:
- double ( ), 8 , : 12.5,.123, 0.5, 1. ( );
- float 4 , f (F), : 10.5f, 0.123F;
- long double 10 , l (L), : 10.5l, 0.9L.
:
- ( ), : 10.125, 1. ( 1.0), .125 ( 0.125), 0.125, , , , , , , , , 0, , 0;
- ( ): 1e-5, 12.23E4F ( float), , ( ), . 10..
- . ANSI , , , , , , a, d, 1, ., , char 1 . , , , ASCII.
, . , \ ( ), - . : \\ - , \ - , \ - , \n ( 10), \r ( 13), \a ( 7), \b () ( 8). , \ooo \xhh, o , h ( 255). , 32 , \x20, \40.
|
|
, , Visual C++ ( 4- ): asdf, GR, int ( ).
- , ( ), - . : \n , . . \0, , .
- . , . . , int.
:
enum <_> {
<1>[=<1>],
<2>[=<2>],
.
<N>[=<N>] };
<1>, <2>, , <N> - , , , 0, 1 .
enum A
{
a, // 0
b, // 1
c=10, // 10
d // 11
};
, int i=b; i 1.
- , , , NULL, , . 0, .
1.2.5.
, , - .
, , , :
=: x=y+10;
, (++ --): i++; --j;
: f1();
: x=i++ + f();
, ( ), , ( ).
:
:
- - (, ), ;
+ - , ;
* - , , (), ;
& - , ();
~ - , , ;
! - ( Ż), 0, ( ), 1, ( Visual C++ bool), , ANSI , 2 : , , , , 0- , , 0 - ;
(<>) , ;
|
|
sizeof , :
sizeof sizeof()
sizeof()
++ - ( 1), -- - ( 1), , , . ( ), . , , , , . ,
int i=10, j;
j=++i; //
, i j 11 ( j i, 1), ++:
int i=10, j;
j=i++; //
, i 11, j 10, j i, 1. , .
:
:
+ - ;
- - ;
* - ;
/ - ;
% - .
: , + - . % .
:
&& - ;
|| - ;
^ - .
, . , (, , , ). Visual C++ int bool .
:
& - ;
| - ;
^ - ;
>> - ;
<< - .
. &, |, ^ ( , , .).
, . << . >> , , .
():
== - ( =);
!= - ;
> - ;
< - ;
>= - ;
<= - .
. . ( 0, , 1) (0). Visual C++ bool.
:
= - .
L -, .. , , . , , , . , L - (L- value) ( , ), , , .
|
|
op= ( op ) , , , += - , : *=, /=, -=, %=, &=, |=, ^= . :
i+=10; i=i+10;
, :
() ;
[ ] ;
. () ;
-> - ;
, () , , , ().
:
?: - .
: <1>? <2>: <3>
, , , , , . ,
y= x>=0? x: -x;
y x.
, . , 15 . , , , ( ). 2, .
.
:
y = a + b * 10; // *, +, =
y = (a + b) * 10; // + (- ), *, =
a = b = c = 100; // = ,
// 100
, ( ) () ().
2
() | |||
() [] ->. | |||
! ~ + - ++ -- & * () sizeof | |||
* / % | |||
+ - | |||
< <= >= > | () | ||
==!= | () | ||
& | |||
^ | |||
| | |||
&& | |||
|| | |||
?: | |||
= *= /= %= += -= &= ^= |= <<= >>= | |||
, ( "") |
:
if (<>) <1>
[ else <2> ]
. : <>, (;) , , , (), , [] ( ), , .. .
, (, , ), 0, , , .
:
if (x>=0) y=x; else y=-x; // y x
, ().
|
|
:
if (x>0) { y=x; z=x+y; }
else { y=-x; z=x*x+y*y; }
, , else, . if .
. :
if (x==1) if (y==1) printf(x==1 and y==1);
else printf(x==1 and y!=1);
else if, if . , if else , . , if else , : else, if, , else if, if ..
if else , . :
if (x==1) { if (y==1) printf(x==1 and y==1); }
else printf(x!=1);
else if, if , else x 1, y .
-
, .. ( ).
:
switch(<_>)
{
case <_1>: <>
case <_2>: <>
..
case <_N>: <>
[ default: <> ]
}
<_> - , , char.
<_X> - .
case <_>:, default ( ), . , . break;
:
int a;
printf("a="); scanf("%d", &a);
switch(a)
{
case 1: printf("\n1");
case 2: printf("\n2");
case 3: printf("\n3");
default:
printf("\n>3");
}
2 :
>3
.. case 2: , , .. . . break; - . :
int a;
printf("a="); scanf_s("%d", &a);
switch(a)
{
case 1: printf("\n1"); break;
case 2: printf("\n2"); break;
case 3: printf("\n3"); break;
default:
printf("\n>3");
}
2 2, break;