SlideShare a Scribd company logo
1 of 2
Download to read offline
C Reference Card (ANSI)                                        Constants                                                           Flow of Control
                                                                 suffix: long, unsigned, float                  65536L, -1U, 3.0F           statement terminator                       ;
Program Structure/Functions                                      exponential form                            4.2e1                       block delimiters                           {}
                                                                 prefix: octal, hexadecimal                   0, 0x or 0X                 exit from switch, while, do, for           break;
type fnc(type 1 , . . . );           function prototype
                                                                      Example. 031 is 25, 0x31 is 49 decimal                             next iteration of while, do, for           continue;
type name;                           variable declaration
                                                                 character constant (char, octal, hex)     'a', 'ooo', 'xhh'           go to                                      goto label;
int main(void) {                     main routine
                                     local variable declarations newline, cr, tab, backspace                 n, r, t, b              label                                      label: statement
   declarations
                                                                 special characters                          , ?, ', quot;              return value from function                 return expr
   statements
                                                                 string constant (ends with '0')            quot;abc. . . dequot;               Flow Constructions
}
                                                                                                                                         if statement              if (expr 1 ) statement 1
type fnc(arg 1 , . . . ) {           function definition
                                     local variable declarations Pointers, Arrays & Structures                                                                     else if (expr 2 ) statement 2
   declarations
                                                                                                                                                                   else statement 3
   statements                                                    declare pointer to type                     type *name;
                                                                                                                                         while statement           while (expr )
   return value;                                                 declare function returning pointer to type type *f();
                                                                                                                                                                     statement
}                                                                declare pointer to function returning type type (*pf)();
                                                                                                                                         for statement             for (expr 1 ; expr 2 ; expr 3 )
/* */                                comments                    generic pointer type                        void *
                                                                                                                                                                     statement
int main(int argc, char *argv[])     main with args              null pointer constant                       NULL
                                                                                                                                         do statement              do    statement
exit(arg);                           terminate execution         object pointed to by pointer                *pointer
                                                                                                                                                                   while(expr );
                                                                 address of object name                      &name
C Preprocessor                                                                                                                           switch statement          switch (expr ) {
                                                                 array                                       name[dim]
                                                                                                                                                                      case const 1 : statement 1 break;
include library file                  #include <filename>          multi-dim array                         name[dim 1 ][dim 2 ]. . .                                    case const 2 : statement 2 break;
include user file                     #include quot;filenamequot;          Structures                                                                                           default: statement
replacement text                      #define name text               struct tag {            structure template                                                   }
replacement macro                #define name(var ) text                declarations          declaration of members
                                                                                                                                         ANSI Standard Libraries
     Example. #define max(A,B) ((A)>(B) ? (A) : (B))                  };
undefine                               #undef name                                                                                        <assert.h>    <ctype.h>    <errno.h>     <float.h>       <limits.h>
                                                                 create structure                            struct tag name
quoted string in replace              #                                                                                                  <locale.h>    <math.h>     <setjmp.h>    <signal.h>      <stdarg.h>
                                                                 member of structure from template           name.member
     Example. #define msg(A) printf(quot;%s = %dquot;, #A, (A))                                                                                  <stddef.h>    <stdio.h>    <stdlib.h>    <string.h>      <time.h>
                                                                 member of pointed-to structure              pointer -> member
concatenate args and rescan           ##                              Example. (*p).x and p->x are the same
                                                                                                                                         Character Class Tests <ctype.h>
conditional execution         #if, #else, #elif, #endif          single object, multiple possible types      union
is name defined, not defined?           #ifdef, #ifndef                                                                                    alphanumeric?                                  isalnum(c)
                                                                 bit field with b bits                     unsigned member : b;
name defined?                          defined(name)                                                                                      alphabetic?                                    isalpha(c)
                                                                 Operators (grouped by precedence)
line continuation char                                                                                                                  control character?                             iscntrl(c)
                                                                                                                                         decimal digit?                                 isdigit(c)
Data Types/Declarations                                              struct member operator                       name.member
                                                                                                                                         printing character (not incl space)?           isgraph(c)
                                                                     struct member through pointer                pointer ->member
character (1 byte)                        char                                                                                           lower case letter?                             islower(c)
                                                                     increment, decrement                         ++, --
integer                                   int                                                                                            printing character (incl space)?               isprint(c)
                                                                     plus, minus, logical not, bitwise not        +, -, !, ~
real number (single, double precision)    float, double                                                                                  printing char except space, letter, digit?     ispunct(c)
                                                                     indirection via pointer, address of object   *pointer , &name
short (16 bit integer)                    short                                                                                          space, formfeed, newline, cr, tab, vtab?       isspace(c)
                                                                     cast expression to type                      (type) expr
long (32 bit integer)                     long                                                                                           upper case letter?                             isupper(c)
                                                                     size of an object                            sizeof
double long (64 bit integer)              long long                                                                                      hexadecimal digit?                             isxdigit(c)
positive or negative                      signed                     multiply, divide, modulus (remainder)        *, /, %                convert to lower case                          tolower(c)
non-negative modulo 2m                    unsigned                                                                                       convert to upper case                          toupper(c)
                                                                     add, subtract                                +, -
pointer to int, float,. . .               int*, float*,. . .
                                                                                                                                         String Operations <string.h>
                                                                     left, right shift [bit ops]                  <<, >>
enumeration constant           enum tag {name 1 =value 1 ,. . . };
                                                                     relational comparisons                       >, >=, <, <=             s is a string; cs, ct are constant strings
constant (read-only) value                type const name;
declare external variable                 extern                     equality comparisons                         ==, !=                 length of s                                    strlen(s)
internal to source file                    static                                                                                         copy ct to s                                   strcpy(s,ct)
                                                                     and [bit op]                                 &
local persistent between calls            static                                                                                         concatenate ct after s                         strcat(s,ct)
                                                                     exclusive or [bit op]                        ^
no value                                  void                                                                                           compare cs to ct                               strcmp(cs,ct)
                                                                     or (inclusive) [bit op]                      |
structure                                 struct tag {. . . };                                                                                only first n chars                         strncmp(cs,ct,n)
create new name for data type            typedef type name;          logical and                                  &&                     pointer to first c in cs                        strchr(cs,c)
size of an object (type is size_t)        sizeof object                                                                                  pointer to last c in cs                        strrchr(cs,c)
                                                                     logical or                                   ||
size of a data type (type is size_t)      sizeof(type)                                                                                   copy n chars from ct to s                      memcpy(s,ct,n)
                                                                     conditional expression                   expr 1 ? expr 2 : expr 3
                                                                                                                                         copy n chars from ct to s (may overlap)        memmove(s,ct,n)
Initialization                                                       assignment operators                         +=, -=, *=, . . .      compare n chars of cs with ct                  memcmp(cs,ct,n)
initialize variable                        type name=value;          expression evaluation separator              ,                      pointer to first c in first n chars of cs        memchr(cs,c,n)
initialize array                    type name[]={value 1 ,. . . };                                                                       put c into first n chars of s                   memset(s,c,n)
                                                                     Unary operators, conditional expression and assignment oper-
initialize char string                  char name[]=quot;stringquot;;        ators group right to left; all others group left to right.
        c 2007 Joseph H. Silverman Permissions on back. v2.2
C Reference Card (ANSI)                                        Standard Utility Functions <stdlib.h>                           Mathematical Functions <math.h>
                                                                                                                                    Arguments and returned values are double
                                                                    absolute value of int n                  abs(n)
Input/Output <stdio.h>                                              absolute value of long n                 labs(n)                trig functions                          sin(x), cos(x), tan(x)
                                                                    quotient and remainder of ints n,d       div(n,d)               inverse trig functions               asin(x), acos(x), atan(x)
Standard I/O
                                                                         returns structure with div_t.quot and div_t.rem            arctan(y/x)                                 atan2(y,x)
standard input stream                      stdin
                                                                    quotient and remainder of longs n,d      ldiv(n,d)              hyperbolic trig functions            sinh(x), cosh(x), tanh(x)
standard output stream                     stdout
                                                                         returns structure with ldiv_t.quot and ldiv_t.rem          exponentials & logs                   exp(x), log(x), log10(x)
standard error stream                      stderr
                                                                    pseudo-random integer [0,RAND_MAX]       rand()                 exponentials & logs (2 power)          ldexp(x,n), frexp(x,&e)
end of file (type is int)                   EOF
                                                                    set random seed to n                     srand(n)               division & remainder                     modf(x,ip), fmod(x,y)
get a character                            getchar()
                                                                    terminate program execution              exit(status)           powers                                      pow(x,y), sqrt(x)
print a character                          putchar(chr )
                                                                    pass string s to system for execution    system(s)              rounding                            ceil(x), floor(x), fabs(x)
print formatted data               printf(quot;formatquot;,arg 1 ,. . . )
                                                                    Conversions
                                                                                                                                    Integer Type Limits <limits.h>
print to string s               sprintf(s,quot;formatquot;,arg 1 ,. . . )
                                                                    convert string s to double               atof(s)
read formatted data              scanf(quot;formatquot;,&name 1 ,. . . )
                                                                    convert string s to integer              atoi(s)                The numbers given in parentheses are typical values for the
read from string s           sscanf(s,quot;formatquot;,&name 1 ,. . . )
                                                                    convert string s to long                 atol(s)                constants on a 32-bit Unix system, followed by minimum re-
print string s                             puts(s)
                                                                    convert prefix of s to double             strtod(s,&endp)        quired values (if significantly different).
File I/O
                                                                    convert prefix of s (base b) to long      strtol(s,&endp,b)       CHAR_BIT bits in char                                      (8)
declare file pointer                        FILE *fp;
                                                                         same, but unsigned long             strtoul(s,&endp,b)      CHAR_MAX max value of char          (SCHAR_MAX or UCHAR_MAX)
pointer to named file                   fopen(quot;namequot;,quot;modequot;)
                                                                    Storage Allocation                                               CHAR_MIN min value of char                    (SCHAR MIN or 0)
     modes: r (read), w (write), a (append), b (binary)
                                                                    allocate storage            malloc(size), calloc(nobj,size)     SCHAR_MAX max signed char                               (+127)
get a character                            getc(fp)
                                                                    change size of storage          newptr = realloc(ptr,size);     SCHAR_MIN min signed char                               (−128)
write a character                          putc(chr ,fp)
                                                                    deallocate storage                       free(ptr);              SHRT_MAX max value of short                         (+32,767)
write to file                   fprintf(fp,quot;formatquot;,arg 1 ,. . . )
                                                                    Array Functions                                                  SHRT_MIN min value of short                         (−32,768)
read from file                   fscanf(fp,quot;formatquot;,arg 1 ,. . . )
                                                                    search array for key         bsearch(key,array,n,size,cmpf)       INT_MAX max value of int         (+2,147,483,647) (+32,767)
read and store n elts to *ptr        fread(*ptr,eltsize,n,fp)
                                                                    sort array ascending order         qsort(array,n,size,cmpf)       INT_MIN min value of int         (−2,147,483,648) (−32,767)
write n elts from *ptr to file      fwrite(*ptr,eltsize,n,fp)
                                                                                                                                     LONG_MAX max value of long                   (+2,147,483,647)
                                                                    Time and Date Functions <time.h>
close file                                  fclose(fp)
                                                                                                                                     LONG_MIN min value of long                   (−2,147,483,648)
non-zero if error                          ferror(fp)
                                                                                                                                    UCHAR_MAX max unsigned char                               (255)
                                                                    processor time used by program            clock()
non-zero if already reached EOF            feof(fp)
                                                                                                                                    USHRT_MAX max unsigned short                           (65,535)
                                                                         Example. clock()/CLOCKS_PER_SEC is time in seconds
read line to string s (< max chars)        fgets(s,max,fp)
                                                                                                                                     UINT_MAX max unsigned int             (4,294,967,295) (65,535)
                                                                    current calendar time                     time()
write string s                             fputs(s,fp)
                                                                                                                                    ULONG_MAX max unsigned long                     (4,294,967,295)
                                                                    time2 -time1 in seconds (double)      difftime(time2 ,time1 )
Codes for Formatted I/O: quot;%-+ 0w.pmcquot;
                                                                    arithmetic types representing times       clock_t,time_t
                                                                                                                                    Float Type Limits <float.h>
       - left justify
                                                                    structure type for calendar time comps        struct tm
       + print with sign
                                                                         tm_sec        seconds after minute                         The numbers given in parentheses are typical values for the
     space print space if no sign
                                                                         tm_min        minutes after hour                           constants on a 32-bit Unix system.
       0 pad with leading zeros
                                                                         tm_hour       hours since midnight                           FLT_RADIX       radix of exponent rep                  (2)
       w min field width
                                                                         tm_mday       day of month                                   FLT_ROUNDS      floating point rounding mode
       p precision
                                                                         tm_mon        months since January                           FLT_DIG         decimal digits of precision            (6)
       m conversion character:
                                                                         tm_year       years since 1900                               FLT_EPSILON     smallest x so 1.0f + x = 1.0f   (1.1E − 7)
                 h short,      l long,      L long double
                                                                         tm_wday       days since Sunday                              FLT_MANT_DIG number of digits in mantissa
       c    conversion character:
                                                                         tm_yday       days since January 1                           FLT_MAX         maximum float number              (3.4E38)
          d,i integer                u unsigned
                                                                         tm_isdst      Daylight Savings Time flag                      FLT_MAX_EXP     maximum exponent
           c single char             s char string
                                                                                                                                      FLT_MIN         minimum float number           (1.2E − 38)
           f double (printf)        e,E exponential                 convert local time to calendar time        mktime(tp)
                                                                                                                                      FLT_MIN_EXP     minimum exponent
           f float (scanf)           lf double (scanf)               convert time in tp to string               asctime(tp)
                                                                                                                                      DBL_DIG         decimal digits of precision           (15)
           o octal                  x,X hexadecimal                 convert calendar time in tp to local time ctime(tp)
                                                                                                                                      DBL_EPSILON     smallest x so 1.0 + x = 1.0    (2.2E − 16)
           p pointer                 n number of chars written      convert calendar time to GMT               gmtime(tp)
                                                                                                                                      DBL_MANT_DIG number of digits in mantissa
          g,G same as f or e,E depending on exponent                convert calendar time to local time        localtime(tp)
                                                                                                                                      DBL_MAX         max double number                (1.8E308)
                                                                    format date and time info      strftime(s,smax,quot;formatquot;,tp)
Variable Argument Lists <stdarg.h>                                                                                                    DBL_MAX_EXP     maximum exponent
                                                                        tp is a pointer to a structure of type tm
                                                                                                                                      DBL_MIN         min double number             (2.2E − 308)
declaration of pointer to arguments       va_list ap;
                                                                                                                                      DBL_MIN_EXP     minimum exponent
initialization of argument pointer     va_start(ap,lastarg);
     lastarg is last named parameter of the function
access next unnamed arg, update pointer va_arg(ap,type)
call before exiting function              va_end(ap);                                                                                    January 2007 v2.2. Copyright c 2007 Joseph H. Silverman
                                                                                                                                    Permission is granted to make and distribute copies of this card pro-
                                                                                                                                    vided the copyright notice and this permission notice are preserved on
                                                                                                                                    all copies.
                                                                                                                                    Send comments and corrections to J.H. Silverman, Math. Dept., Brown
                                                                                                                                    Univ., Providence, RI 02912 USA. jhs@math.brown.edu

More Related Content

What's hot

What's hot (18)

Functions
FunctionsFunctions
Functions
 
All About ... Functions
All About ... FunctionsAll About ... Functions
All About ... Functions
 
Introduction to ad-3.4, an automatic differentiation library in Haskell
Introduction to ad-3.4, an automatic differentiation library in HaskellIntroduction to ad-3.4, an automatic differentiation library in Haskell
Introduction to ad-3.4, an automatic differentiation library in Haskell
 
Preprocessor Programming
Preprocessor ProgrammingPreprocessor Programming
Preprocessor Programming
 
A regex ekon16
A regex ekon16A regex ekon16
A regex ekon16
 
Core c sharp and .net quick reference
Core c sharp and .net quick referenceCore c sharp and .net quick reference
Core c sharp and .net quick reference
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
strings
stringsstrings
strings
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
Unit 2
Unit 2Unit 2
Unit 2
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
 
7 functions
7  functions7  functions
7 functions
 
Computer Network Assignment Help
Computer Network Assignment HelpComputer Network Assignment Help
Computer Network Assignment Help
 
What's New in C++ 11?
What's New in C++ 11?What's New in C++ 11?
What's New in C++ 11?
 
C++11: Rvalue References, Move Semantics, Perfect Forwarding
C++11: Rvalue References, Move Semantics, Perfect ForwardingC++11: Rvalue References, Move Semantics, Perfect Forwarding
C++11: Rvalue References, Move Semantics, Perfect Forwarding
 

Viewers also liked

ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARDTia Ricci
 
Prog web 03-php-sessoes-cookies_cabecalhos
Prog web 03-php-sessoes-cookies_cabecalhosProg web 03-php-sessoes-cookies_cabecalhos
Prog web 03-php-sessoes-cookies_cabecalhosRegis Magalhães
 
Creating an Evolving Social Technology Strategy
Creating an Evolving Social Technology StrategyCreating an Evolving Social Technology Strategy
Creating an Evolving Social Technology StrategyPerficient, Inc.
 
Technological applications and innovations
Technological applications and innovationsTechnological applications and innovations
Technological applications and innovationsrbulalakaw
 
Sovereignty, Free Will, and Salvation - Limited Atonement
Sovereignty, Free Will, and Salvation - Limited AtonementSovereignty, Free Will, and Salvation - Limited Atonement
Sovereignty, Free Will, and Salvation - Limited AtonementRobin Schumacher
 
Comm skills1
Comm skills1Comm skills1
Comm skills1Raj Kaur
 
user: Roo-user-Ob-PicklistMulti-Value-minimal uploder
  user: Roo-user-Ob-PicklistMulti-Value-minimal uploder  user: Roo-user-Ob-PicklistMulti-Value-minimal uploder
user: Roo-user-Ob-PicklistMulti-Value-minimal uploderRoopa slideshare
 
Torishima Pump general catalogue, Venezuela, Central America, Caribbean
Torishima Pump general catalogue, Venezuela, Central America, CaribbeanTorishima Pump general catalogue, Venezuela, Central America, Caribbean
Torishima Pump general catalogue, Venezuela, Central America, CaribbeanP&L International Trading
 
English Catcher in the Rye - Mid unit test
English Catcher in the Rye - Mid unit testEnglish Catcher in the Rye - Mid unit test
English Catcher in the Rye - Mid unit testphychedelicmasquerade
 
Focusing on the Threats to the Detriment of the Vulnerabilities
Focusing on the Threats to the Detriment of the VulnerabilitiesFocusing on the Threats to the Detriment of the Vulnerabilities
Focusing on the Threats to the Detriment of the VulnerabilitiesRoger Johnston
 
Earned value management lecture 2009e my31
Earned value management lecture 2009e my31Earned value management lecture 2009e my31
Earned value management lecture 2009e my31rongo620
 
Nccit2014 pitipark
Nccit2014 pitiparkNccit2014 pitipark
Nccit2014 pitiparkAJ Pinrod
 
SAMA nominees 2015
SAMA nominees 2015SAMA nominees 2015
SAMA nominees 2015SABC News
 
Intro to developing for @twitterapi (updated)
Intro to developing for @twitterapi (updated)Intro to developing for @twitterapi (updated)
Intro to developing for @twitterapi (updated)Raffi Krikorian
 

Viewers also liked (20)

ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARD
 
Prog web 03-php-sessoes-cookies_cabecalhos
Prog web 03-php-sessoes-cookies_cabecalhosProg web 03-php-sessoes-cookies_cabecalhos
Prog web 03-php-sessoes-cookies_cabecalhos
 
Creating an Evolving Social Technology Strategy
Creating an Evolving Social Technology StrategyCreating an Evolving Social Technology Strategy
Creating an Evolving Social Technology Strategy
 
Technological applications and innovations
Technological applications and innovationsTechnological applications and innovations
Technological applications and innovations
 
Sovereignty, Free Will, and Salvation - Limited Atonement
Sovereignty, Free Will, and Salvation - Limited AtonementSovereignty, Free Will, and Salvation - Limited Atonement
Sovereignty, Free Will, and Salvation - Limited Atonement
 
Comm skills1
Comm skills1Comm skills1
Comm skills1
 
user: Roo-user-Ob-PicklistMulti-Value-minimal uploder
  user: Roo-user-Ob-PicklistMulti-Value-minimal uploder  user: Roo-user-Ob-PicklistMulti-Value-minimal uploder
user: Roo-user-Ob-PicklistMulti-Value-minimal uploder
 
Torishima Pump general catalogue, Venezuela, Central America, Caribbean
Torishima Pump general catalogue, Venezuela, Central America, CaribbeanTorishima Pump general catalogue, Venezuela, Central America, Caribbean
Torishima Pump general catalogue, Venezuela, Central America, Caribbean
 
Planejamento pms
Planejamento pmsPlanejamento pms
Planejamento pms
 
English Catcher in the Rye - Mid unit test
English Catcher in the Rye - Mid unit testEnglish Catcher in the Rye - Mid unit test
English Catcher in the Rye - Mid unit test
 
Focusing on the Threats to the Detriment of the Vulnerabilities
Focusing on the Threats to the Detriment of the VulnerabilitiesFocusing on the Threats to the Detriment of the Vulnerabilities
Focusing on the Threats to the Detriment of the Vulnerabilities
 
nullcon 2011 - Buffer UnderRun Exploits
nullcon 2011 - Buffer UnderRun Exploitsnullcon 2011 - Buffer UnderRun Exploits
nullcon 2011 - Buffer UnderRun Exploits
 
FibreTuff FPS 12th
FibreTuff FPS   12thFibreTuff FPS   12th
FibreTuff FPS 12th
 
Earned value management lecture 2009e my31
Earned value management lecture 2009e my31Earned value management lecture 2009e my31
Earned value management lecture 2009e my31
 
Nccit2014 pitipark
Nccit2014 pitiparkNccit2014 pitipark
Nccit2014 pitipark
 
CIF ppt 21.12.12
CIF ppt 21.12.12CIF ppt 21.12.12
CIF ppt 21.12.12
 
SAMA nominees 2015
SAMA nominees 2015SAMA nominees 2015
SAMA nominees 2015
 
Teens24
Teens24Teens24
Teens24
 
Intro to developing for @twitterapi (updated)
Intro to developing for @twitterapi (updated)Intro to developing for @twitterapi (updated)
Intro to developing for @twitterapi (updated)
 
Modul 1 bahasa indonesia kb 1
Modul 1 bahasa indonesia kb 1Modul 1 bahasa indonesia kb 1
Modul 1 bahasa indonesia kb 1
 

Similar to C Reference Card (Ansi) 2

Cartão de Referencia Padronizado Liguagem C
Cartão de Referencia Padronizado Liguagem  CCartão de Referencia Padronizado Liguagem  C
Cartão de Referencia Padronizado Liguagem CGe Ramos
 
NaBL: A Meta-Language for Declarative Name Binding and Scope Rules
NaBL: A Meta-Language for Declarative Name Binding  and Scope RulesNaBL: A Meta-Language for Declarative Name Binding  and Scope Rules
NaBL: A Meta-Language for Declarative Name Binding and Scope RulesEelco Visser
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1Little Tukta Lita
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1AmIt Prasad
 
Testing for share
Testing for share Testing for share
Testing for share Rajeev Mehta
 
presentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.pptpresentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.pptSandipPradhan23
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1Little Tukta Lita
 
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Coen De Roover
 
Introduction of flex
Introduction of flexIntroduction of flex
Introduction of flexvip_du
 
Verification with LoLA: 2 The LoLA Input Language
Verification with LoLA: 2 The LoLA Input LanguageVerification with LoLA: 2 The LoLA Input Language
Verification with LoLA: 2 The LoLA Input LanguageUniversität Rostock
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaBrian Hsu
 
C standard library functions
C standard library functionsC standard library functions
C standard library functionsVaishnavee Sharma
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it outrajatryadav22
 
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...Muhammad Ulhaque
 

Similar to C Reference Card (Ansi) 2 (20)

C ref card
C ref cardC ref card
C ref card
 
Cartão de Referencia Padronizado Liguagem C
Cartão de Referencia Padronizado Liguagem  CCartão de Referencia Padronizado Liguagem  C
Cartão de Referencia Padronizado Liguagem C
 
NaBL: A Meta-Language for Declarative Name Binding and Scope Rules
NaBL: A Meta-Language for Declarative Name Binding  and Scope RulesNaBL: A Meta-Language for Declarative Name Binding  and Scope Rules
NaBL: A Meta-Language for Declarative Name Binding and Scope Rules
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
Testing for share
Testing for share Testing for share
Testing for share
 
ch08.ppt
ch08.pptch08.ppt
ch08.ppt
 
presentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.pptpresentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.ppt
 
Cpprm
CpprmCpprm
Cpprm
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
 
CC Week 11.ppt
CC Week 11.pptCC Week 11.ppt
CC Week 11.ppt
 
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012
 
C# programming
C# programming C# programming
C# programming
 
Unit 8
Unit 8Unit 8
Unit 8
 
Introduction of flex
Introduction of flexIntroduction of flex
Introduction of flex
 
Verification with LoLA: 2 The LoLA Input Language
Verification with LoLA: 2 The LoLA Input LanguageVerification with LoLA: 2 The LoLA Input Language
Verification with LoLA: 2 The LoLA Input Language
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
C standard library functions
C standard library functionsC standard library functions
C standard library functions
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
 
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
 

More from Regis Magalhães

Prog web 01-php-introducao
Prog web 01-php-introducaoProg web 01-php-introducao
Prog web 01-php-introducaoRegis Magalhães
 
Prog web 02-php-primeiros-passos
Prog web 02-php-primeiros-passosProg web 02-php-primeiros-passos
Prog web 02-php-primeiros-passosRegis Magalhães
 
Prog web 00-modelo-cliente_servidor_web
Prog web 00-modelo-cliente_servidor_webProg web 00-modelo-cliente_servidor_web
Prog web 00-modelo-cliente_servidor_webRegis Magalhães
 
Prog web 03-php-sessoes-cookies_cabecalhos
Prog web 03-php-sessoes-cookies_cabecalhosProg web 03-php-sessoes-cookies_cabecalhos
Prog web 03-php-sessoes-cookies_cabecalhosRegis Magalhães
 
Prog web 02-php-primeiros-passos
Prog web 02-php-primeiros-passosProg web 02-php-primeiros-passos
Prog web 02-php-primeiros-passosRegis Magalhães
 
Prog web 02-php-primeiros-passos
Prog web 02-php-primeiros-passosProg web 02-php-primeiros-passos
Prog web 02-php-primeiros-passosRegis Magalhães
 
Prog web 00-modelo-cliente_servidor_web
Prog web 00-modelo-cliente_servidor_webProg web 00-modelo-cliente_servidor_web
Prog web 00-modelo-cliente_servidor_webRegis Magalhães
 
Prog web 01-php-introducao
Prog web 01-php-introducaoProg web 01-php-introducao
Prog web 01-php-introducaoRegis Magalhães
 
Linked Data Tutorial - Conferencia W3C Brasil 2011
Linked Data Tutorial - Conferencia W3C Brasil 2011Linked Data Tutorial - Conferencia W3C Brasil 2011
Linked Data Tutorial - Conferencia W3C Brasil 2011Regis Magalhães
 
Linked Data - Minicurso - SBBD 2011
Linked Data - Minicurso - SBBD 2011Linked Data - Minicurso - SBBD 2011
Linked Data - Minicurso - SBBD 2011Regis Magalhães
 

More from Regis Magalhães (20)

High Dimensional Data
High Dimensional DataHigh Dimensional Data
High Dimensional Data
 
Web Scale Data Management
Web Scale Data ManagementWeb Scale Data Management
Web Scale Data Management
 
PHP 10 CodeIgniter
PHP 10 CodeIgniterPHP 10 CodeIgniter
PHP 10 CodeIgniter
 
Prog web 01-php-introducao
Prog web 01-php-introducaoProg web 01-php-introducao
Prog web 01-php-introducao
 
Prog web 02-php-primeiros-passos
Prog web 02-php-primeiros-passosProg web 02-php-primeiros-passos
Prog web 02-php-primeiros-passos
 
Prog web 00-modelo-cliente_servidor_web
Prog web 00-modelo-cliente_servidor_webProg web 00-modelo-cliente_servidor_web
Prog web 00-modelo-cliente_servidor_web
 
Prog web 09-php-crud-mvc
Prog web 09-php-crud-mvcProg web 09-php-crud-mvc
Prog web 09-php-crud-mvc
 
Prog web 08-php-mvc
Prog web 08-php-mvcProg web 08-php-mvc
Prog web 08-php-mvc
 
Prog web 07-pdo
Prog web 07-pdoProg web 07-pdo
Prog web 07-pdo
 
Prog web 06-php-oo
Prog web 06-php-ooProg web 06-php-oo
Prog web 06-php-oo
 
Prog web 05-php-mysql
Prog web 05-php-mysqlProg web 05-php-mysql
Prog web 05-php-mysql
 
Prog web 04-php-gd
Prog web 04-php-gdProg web 04-php-gd
Prog web 04-php-gd
 
Prog web 03-php-sessoes-cookies_cabecalhos
Prog web 03-php-sessoes-cookies_cabecalhosProg web 03-php-sessoes-cookies_cabecalhos
Prog web 03-php-sessoes-cookies_cabecalhos
 
Prog web 02-php-primeiros-passos
Prog web 02-php-primeiros-passosProg web 02-php-primeiros-passos
Prog web 02-php-primeiros-passos
 
Prog web 02-php-primeiros-passos
Prog web 02-php-primeiros-passosProg web 02-php-primeiros-passos
Prog web 02-php-primeiros-passos
 
Prog web 00-modelo-cliente_servidor_web
Prog web 00-modelo-cliente_servidor_webProg web 00-modelo-cliente_servidor_web
Prog web 00-modelo-cliente_servidor_web
 
Prog web 01-php-introducao
Prog web 01-php-introducaoProg web 01-php-introducao
Prog web 01-php-introducao
 
Linked Data Tutorial - Conferencia W3C Brasil 2011
Linked Data Tutorial - Conferencia W3C Brasil 2011Linked Data Tutorial - Conferencia W3C Brasil 2011
Linked Data Tutorial - Conferencia W3C Brasil 2011
 
Linked Data - Minicurso - SBBD 2011
Linked Data - Minicurso - SBBD 2011Linked Data - Minicurso - SBBD 2011
Linked Data - Minicurso - SBBD 2011
 
Curso Ruby
Curso RubyCurso Ruby
Curso Ruby
 

Recently uploaded

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

C Reference Card (Ansi) 2

  • 1. C Reference Card (ANSI) Constants Flow of Control suffix: long, unsigned, float 65536L, -1U, 3.0F statement terminator ; Program Structure/Functions exponential form 4.2e1 block delimiters {} prefix: octal, hexadecimal 0, 0x or 0X exit from switch, while, do, for break; type fnc(type 1 , . . . ); function prototype Example. 031 is 25, 0x31 is 49 decimal next iteration of while, do, for continue; type name; variable declaration character constant (char, octal, hex) 'a', 'ooo', 'xhh' go to goto label; int main(void) { main routine local variable declarations newline, cr, tab, backspace n, r, t, b label label: statement declarations special characters , ?, ', quot; return value from function return expr statements string constant (ends with '0') quot;abc. . . dequot; Flow Constructions } if statement if (expr 1 ) statement 1 type fnc(arg 1 , . . . ) { function definition local variable declarations Pointers, Arrays & Structures else if (expr 2 ) statement 2 declarations else statement 3 statements declare pointer to type type *name; while statement while (expr ) return value; declare function returning pointer to type type *f(); statement } declare pointer to function returning type type (*pf)(); for statement for (expr 1 ; expr 2 ; expr 3 ) /* */ comments generic pointer type void * statement int main(int argc, char *argv[]) main with args null pointer constant NULL do statement do statement exit(arg); terminate execution object pointed to by pointer *pointer while(expr ); address of object name &name C Preprocessor switch statement switch (expr ) { array name[dim] case const 1 : statement 1 break; include library file #include <filename> multi-dim array name[dim 1 ][dim 2 ]. . . case const 2 : statement 2 break; include user file #include quot;filenamequot; Structures default: statement replacement text #define name text struct tag { structure template } replacement macro #define name(var ) text declarations declaration of members ANSI Standard Libraries Example. #define max(A,B) ((A)>(B) ? (A) : (B)) }; undefine #undef name <assert.h> <ctype.h> <errno.h> <float.h> <limits.h> create structure struct tag name quoted string in replace # <locale.h> <math.h> <setjmp.h> <signal.h> <stdarg.h> member of structure from template name.member Example. #define msg(A) printf(quot;%s = %dquot;, #A, (A)) <stddef.h> <stdio.h> <stdlib.h> <string.h> <time.h> member of pointed-to structure pointer -> member concatenate args and rescan ## Example. (*p).x and p->x are the same Character Class Tests <ctype.h> conditional execution #if, #else, #elif, #endif single object, multiple possible types union is name defined, not defined? #ifdef, #ifndef alphanumeric? isalnum(c) bit field with b bits unsigned member : b; name defined? defined(name) alphabetic? isalpha(c) Operators (grouped by precedence) line continuation char control character? iscntrl(c) decimal digit? isdigit(c) Data Types/Declarations struct member operator name.member printing character (not incl space)? isgraph(c) struct member through pointer pointer ->member character (1 byte) char lower case letter? islower(c) increment, decrement ++, -- integer int printing character (incl space)? isprint(c) plus, minus, logical not, bitwise not +, -, !, ~ real number (single, double precision) float, double printing char except space, letter, digit? ispunct(c) indirection via pointer, address of object *pointer , &name short (16 bit integer) short space, formfeed, newline, cr, tab, vtab? isspace(c) cast expression to type (type) expr long (32 bit integer) long upper case letter? isupper(c) size of an object sizeof double long (64 bit integer) long long hexadecimal digit? isxdigit(c) positive or negative signed multiply, divide, modulus (remainder) *, /, % convert to lower case tolower(c) non-negative modulo 2m unsigned convert to upper case toupper(c) add, subtract +, - pointer to int, float,. . . int*, float*,. . . String Operations <string.h> left, right shift [bit ops] <<, >> enumeration constant enum tag {name 1 =value 1 ,. . . }; relational comparisons >, >=, <, <= s is a string; cs, ct are constant strings constant (read-only) value type const name; declare external variable extern equality comparisons ==, != length of s strlen(s) internal to source file static copy ct to s strcpy(s,ct) and [bit op] & local persistent between calls static concatenate ct after s strcat(s,ct) exclusive or [bit op] ^ no value void compare cs to ct strcmp(cs,ct) or (inclusive) [bit op] | structure struct tag {. . . }; only first n chars strncmp(cs,ct,n) create new name for data type typedef type name; logical and && pointer to first c in cs strchr(cs,c) size of an object (type is size_t) sizeof object pointer to last c in cs strrchr(cs,c) logical or || size of a data type (type is size_t) sizeof(type) copy n chars from ct to s memcpy(s,ct,n) conditional expression expr 1 ? expr 2 : expr 3 copy n chars from ct to s (may overlap) memmove(s,ct,n) Initialization assignment operators +=, -=, *=, . . . compare n chars of cs with ct memcmp(cs,ct,n) initialize variable type name=value; expression evaluation separator , pointer to first c in first n chars of cs memchr(cs,c,n) initialize array type name[]={value 1 ,. . . }; put c into first n chars of s memset(s,c,n) Unary operators, conditional expression and assignment oper- initialize char string char name[]=quot;stringquot;; ators group right to left; all others group left to right. c 2007 Joseph H. Silverman Permissions on back. v2.2
  • 2. C Reference Card (ANSI) Standard Utility Functions <stdlib.h> Mathematical Functions <math.h> Arguments and returned values are double absolute value of int n abs(n) Input/Output <stdio.h> absolute value of long n labs(n) trig functions sin(x), cos(x), tan(x) quotient and remainder of ints n,d div(n,d) inverse trig functions asin(x), acos(x), atan(x) Standard I/O returns structure with div_t.quot and div_t.rem arctan(y/x) atan2(y,x) standard input stream stdin quotient and remainder of longs n,d ldiv(n,d) hyperbolic trig functions sinh(x), cosh(x), tanh(x) standard output stream stdout returns structure with ldiv_t.quot and ldiv_t.rem exponentials & logs exp(x), log(x), log10(x) standard error stream stderr pseudo-random integer [0,RAND_MAX] rand() exponentials & logs (2 power) ldexp(x,n), frexp(x,&e) end of file (type is int) EOF set random seed to n srand(n) division & remainder modf(x,ip), fmod(x,y) get a character getchar() terminate program execution exit(status) powers pow(x,y), sqrt(x) print a character putchar(chr ) pass string s to system for execution system(s) rounding ceil(x), floor(x), fabs(x) print formatted data printf(quot;formatquot;,arg 1 ,. . . ) Conversions Integer Type Limits <limits.h> print to string s sprintf(s,quot;formatquot;,arg 1 ,. . . ) convert string s to double atof(s) read formatted data scanf(quot;formatquot;,&name 1 ,. . . ) convert string s to integer atoi(s) The numbers given in parentheses are typical values for the read from string s sscanf(s,quot;formatquot;,&name 1 ,. . . ) convert string s to long atol(s) constants on a 32-bit Unix system, followed by minimum re- print string s puts(s) convert prefix of s to double strtod(s,&endp) quired values (if significantly different). File I/O convert prefix of s (base b) to long strtol(s,&endp,b) CHAR_BIT bits in char (8) declare file pointer FILE *fp; same, but unsigned long strtoul(s,&endp,b) CHAR_MAX max value of char (SCHAR_MAX or UCHAR_MAX) pointer to named file fopen(quot;namequot;,quot;modequot;) Storage Allocation CHAR_MIN min value of char (SCHAR MIN or 0) modes: r (read), w (write), a (append), b (binary) allocate storage malloc(size), calloc(nobj,size) SCHAR_MAX max signed char (+127) get a character getc(fp) change size of storage newptr = realloc(ptr,size); SCHAR_MIN min signed char (−128) write a character putc(chr ,fp) deallocate storage free(ptr); SHRT_MAX max value of short (+32,767) write to file fprintf(fp,quot;formatquot;,arg 1 ,. . . ) Array Functions SHRT_MIN min value of short (−32,768) read from file fscanf(fp,quot;formatquot;,arg 1 ,. . . ) search array for key bsearch(key,array,n,size,cmpf) INT_MAX max value of int (+2,147,483,647) (+32,767) read and store n elts to *ptr fread(*ptr,eltsize,n,fp) sort array ascending order qsort(array,n,size,cmpf) INT_MIN min value of int (−2,147,483,648) (−32,767) write n elts from *ptr to file fwrite(*ptr,eltsize,n,fp) LONG_MAX max value of long (+2,147,483,647) Time and Date Functions <time.h> close file fclose(fp) LONG_MIN min value of long (−2,147,483,648) non-zero if error ferror(fp) UCHAR_MAX max unsigned char (255) processor time used by program clock() non-zero if already reached EOF feof(fp) USHRT_MAX max unsigned short (65,535) Example. clock()/CLOCKS_PER_SEC is time in seconds read line to string s (< max chars) fgets(s,max,fp) UINT_MAX max unsigned int (4,294,967,295) (65,535) current calendar time time() write string s fputs(s,fp) ULONG_MAX max unsigned long (4,294,967,295) time2 -time1 in seconds (double) difftime(time2 ,time1 ) Codes for Formatted I/O: quot;%-+ 0w.pmcquot; arithmetic types representing times clock_t,time_t Float Type Limits <float.h> - left justify structure type for calendar time comps struct tm + print with sign tm_sec seconds after minute The numbers given in parentheses are typical values for the space print space if no sign tm_min minutes after hour constants on a 32-bit Unix system. 0 pad with leading zeros tm_hour hours since midnight FLT_RADIX radix of exponent rep (2) w min field width tm_mday day of month FLT_ROUNDS floating point rounding mode p precision tm_mon months since January FLT_DIG decimal digits of precision (6) m conversion character: tm_year years since 1900 FLT_EPSILON smallest x so 1.0f + x = 1.0f (1.1E − 7) h short, l long, L long double tm_wday days since Sunday FLT_MANT_DIG number of digits in mantissa c conversion character: tm_yday days since January 1 FLT_MAX maximum float number (3.4E38) d,i integer u unsigned tm_isdst Daylight Savings Time flag FLT_MAX_EXP maximum exponent c single char s char string FLT_MIN minimum float number (1.2E − 38) f double (printf) e,E exponential convert local time to calendar time mktime(tp) FLT_MIN_EXP minimum exponent f float (scanf) lf double (scanf) convert time in tp to string asctime(tp) DBL_DIG decimal digits of precision (15) o octal x,X hexadecimal convert calendar time in tp to local time ctime(tp) DBL_EPSILON smallest x so 1.0 + x = 1.0 (2.2E − 16) p pointer n number of chars written convert calendar time to GMT gmtime(tp) DBL_MANT_DIG number of digits in mantissa g,G same as f or e,E depending on exponent convert calendar time to local time localtime(tp) DBL_MAX max double number (1.8E308) format date and time info strftime(s,smax,quot;formatquot;,tp) Variable Argument Lists <stdarg.h> DBL_MAX_EXP maximum exponent tp is a pointer to a structure of type tm DBL_MIN min double number (2.2E − 308) declaration of pointer to arguments va_list ap; DBL_MIN_EXP minimum exponent initialization of argument pointer va_start(ap,lastarg); lastarg is last named parameter of the function access next unnamed arg, update pointer va_arg(ap,type) call before exiting function va_end(ap); January 2007 v2.2. Copyright c 2007 Joseph H. Silverman Permission is granted to make and distribute copies of this card pro- vided the copyright notice and this permission notice are preserved on all copies. Send comments and corrections to J.H. Silverman, Math. Dept., Brown Univ., Providence, RI 02912 USA. jhs@math.brown.edu