[ Pobierz całość w formacie PDF ]

*doublep; };
int
*ap, x, c;
ap = &args; /* argument pointer
*/
for ( ; ; ) {
while((c =
*fmt++) != ´%´) {
if(c == ´\0´)
return;
-
C Reference Manual - 24
putchar(c);
}
switch (c =
*fmt++) {
/* decimal
*/
case ´d´:
x =
*ap++;
if(x
x = -x;
if(x
*/
printf("-32768");
continue;
}
putchar(´-´);
}
printd(x);
continue;
/* octal
*/
case ´o´:
printo(*ap++);
continue;
/* float, double
*/
case ´f´:
/* let ftoa do the real work
*/
ftoa(*ap.doublep++);
continue;
/* character
*/
case ´c´:
putchar(*ap++);
continue;
/* string
*/
case ´s´:
s =
*ap.charpp++;
while(c =
*s++)
putchar(c);
continue;
}
putchar(c);
}
}
/*
Print n in decimal; n must be non-negative
*
*/
printd(n)
{
int a;
if (a=n/10)
printd(a);
putchar(n%10 + ´0´);
}
/*
Print n in octal, with exactly 1 leading 0
*
*/
printo(n)
{
if (n)
printo((n>>3)&017777);
putchar((n&07)+´0´);
}
-
C Reference Manual - 25
REFERENCES
1. Johnson, S. C., and Kernighan, B. W.   The Programming Language B.  Comp. Sci. Tech. Rep. #8., Bell Lab-
oratories, 1972.
2. Ritchie, D. M., and Thompson, K. L.   The UNIX Time-sharing System.  C. ACM7, 17, July, 1974, pp.
365-375.
3. Peterson, T. G., and Lesk, M. E.   A User s Guide to the C Language on the IBM 370.  Internal Memoran-
dum, Bell Laboratories, 1974.
4. Thompson, K. L., and Ritchie, D. M. UNIX Programmer s Manual. Bell Laboratories, 1973.
5. Lesk, M. E., and Barres, B. A.   The GCOS C Library.  Internal memorandum, Bell Laboratories, 1974.
6. Kernighan, B. W.   Programming in C- A Tutorial.  Unpublished internal memorandum, Bell Laboratories,
1974.
-
C Reference Manual - 26
APPENDIX 1
Syntax Summary
1. Expressions.
expression:
primary
expression
*
&expression
- expression
!expression
expression
Ü
++ lvalue
-- lvalue
lvalue ++
lvalue --
sizeof expression
expression binop expression
expression?expression:expression
lvalue asgnop expression
expression,expression
primary:
identifier
constant
string
( expression)
primary( expression-listopt)
primary[expression]
lvalue. identifier
primary Þ> identifier
lvalue:
identifier
primary[ expression]
lvalue. identifier
primary Þ>identifier
expression
*
( lvalue)
The primary-expression operators
() [] . Þ>
have highest priority and group left-to-right. The unary operators
& - ! ++ -- sizeof
~
have priority below the primary operators but higher than any binary operator, and group right-to-left. Bi-
nary operators and the conditional operator all group left-to-right, and have priority decreasing as indicated:
binop:
/ %
*
+ -
>>
=
== !=
&
-
C Reference Manual - 27
^
|
&&
||
? :
Assignment operators all have the same priority, and all group right-to-left.
asgnop:
= =+ =- =* =/ =% =>> =
The comma operator has the lowest priority, and groups left-to-right.
2. Declarations.
declaration:
decl-specifiers declarator-listopt ;
decl-specifiers:
type-specifier
sc-specifier
type-specifier sc-specifier
sc-specifier type-specifier
sc-specifier:
auto
static
extern
register
type-specifier:
int
char
float
double
struct { type-decl-list }
struct identifier { type-decl-list }
struct identifier
declarator-list:
declarator
declarator,declarator-list
declarator:
identifier
declarator
*
declarator( )
declarator[constant-expressionopt]
( declarator)
type-decl-list:
type-declaration
type-declaration type-decl-list
type-declaration:
type-specifier declarator-list;
3. Statements.
statement:
expression;
{ statement-list }
-
C Reference Manual - 28
if ( expression) statement
if ( expression) statementelse statement
while ( expression) statement
for ( expressionopt; expressionopt; expressionopt) statement
switch ( expression) statement
case constant-expression:statement
default : statement
break ;
continue ;
return ;
return ( expression) ;
goto expression;
identifier: statement
;
statement-list:
statement
statement statement-list
4. External definitions.
program:
external-definition
external-definition program
external-definition:
function-definition
data-definition
function-definition:
type-specifieropt function-declarator function-body
function-declarator:
declarator( parameter-listopt)
parameter-list:
identifier
identifier,parameter-list
function-body:
type-decl-list function-statement
function-statement:
{ declaration-listopt statement-list }
data-definition:
externopt type-specifieropt init-declarator-listopt;
init-declarator-list:
init-declarator
init-declarator,init-declarator-list
init-declarator:
declarator initializeropt
initializer:
constant
{ constant-expression-list }
- [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • girl1.opx.pl
  •