SlideShare a Scribd company logo
1 of 2
Download to read offline
C Reference Card (ANSI) 
Program Structure/Functions 
type fnc(type1,: : : ) function declarations 
type name external variable declarations 
main() { main routine 
declarations local variable declarations 
statements 
} 
type fnc(arg1,: : : ) { function de
nition 
declarations local variable declarations 
statements 
return value; 
} 
/* */ comments 
main(int argc, char *argv[]) main with args 
exit(arg) terminate execution 
C Preprocessor 
include library

More Related Content

What's hot (18)

All About ... Functions
All About ... FunctionsAll About ... Functions
All About ... Functions
 
Functions
FunctionsFunctions
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
 
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
 
Preprocessor Programming
Preprocessor ProgrammingPreprocessor Programming
Preprocessor Programming
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Vi CheatSheet
Vi CheatSheetVi CheatSheet
Vi CheatSheet
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
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
 
Software Construction Assignment Help
Software Construction Assignment HelpSoftware Construction Assignment Help
Software Construction 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?
 

Similar to ANSI C REFERENCE CARD

Type header file in c++ and its function
Type header file in c++ and its functionType header file in c++ and its function
Type header file in c++ and its functionFrankie Jones
 
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
 
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
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)gekiaruj
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and stringsRai University
 
Bsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsBsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsRai University
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1Little Tukta Lita
 
Btech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsBtech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsRai University
 
Functions torage class and array and strings-
Functions torage class and array and strings-Functions torage class and array and strings-
Functions torage class and array and strings-aneebkmct
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)Saifur Rahman
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Sheik Uduman Ali
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and stringsRai University
 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsRai University
 

Similar to ANSI C REFERENCE CARD (20)

Type header file in c++ and its function
Type header file in c++ and its functionType header file in c++ and its function
Type header file in c++ and its function
 
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
 
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
 
Tut1
Tut1Tut1
Tut1
 
Ch3
Ch3Ch3
Ch3
 
Header file.pptx
Header file.pptxHeader file.pptx
Header file.pptx
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and strings
 
Bsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsBsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and strings
 
Strings
StringsStrings
Strings
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
 
Unit 2- Module 2.pptx
Unit 2- Module 2.pptxUnit 2- Module 2.pptx
Unit 2- Module 2.pptx
 
Ch2
Ch2Ch2
Ch2
 
Btech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsBtech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and strings
 
Functions torage class and array and strings-
Functions torage class and array and strings-Functions torage class and array and strings-
Functions torage class and array and strings-
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and strings
 

Recently uploaded

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 

Recently uploaded (20)

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 

ANSI C REFERENCE CARD

  • 1. C Reference Card (ANSI) Program Structure/Functions type fnc(type1,: : : ) function declarations type name external variable declarations main() { main routine declarations local variable declarations statements } type fnc(arg1,: : : ) { function de
  • 2. nition declarations local variable declarations statements return value; } /* */ comments main(int argc, char *argv[]) main with args exit(arg) terminate execution C Preprocessor include library
  • 6. lename" replacement text #define name text replacement macro #define name(var) text Example. #define max(A,B) ((A)>(B) ? (A) : (B)) unde
  • 7. ne #undef name quoted string in replace # concatenate args and rescan ## conditional execution #if, #else, #elif, #endif is name de
  • 10. ned? defined(name) line continuation char Data Types/Declarations character (1 byte) char integer int oat (single precision) float oat (double precision) double short (16 bit integer) short long (32 bit integer) long positive and negative signed only positive unsigned pointer to int, float,: : : *int, *float,: : : enumeration constant enum constant (unchanging) value const declare external variable extern register variable register local to source
  • 11. le static no value void structure struct create name by data type typedef typename size of an object (type is size_t) sizeof object size of a data type (type is size_t) sizeof(type name) Initialization initialize variable type name=value initialize array type name[]={value1,: : : } initialize char string char name[]="string" c 1999 Joseph H. Silverman Permissions on back. v1.3 Constants long (sux) L or l oat (sux) F or f exponential form e octal (pre
  • 12. x zero) 0 hexadecimal (pre
  • 13. x zero-ex) 0x or 0X character constant (char, octal, hex) a , ooo , xhh newline, cr, tab, backspace n, r, t, b special characters , ?, , string constant (ends with 0 ) abc: : : de Pointers, Arrays Structures declare pointer to type type *name declare function returning pointer to type type *f() declare pointer to function returning type type (*pf)() generic pointer type void * null pointer NULL object pointed to by pointer *pointer address of object name name array name[dim] multi-dim array name[dim1][dim2]: : : Structures struct tag { structure template declarations declaration of members }; create structure struct tag name member of structure from template name.member member of pointed to structure pointer - member Example. (*p).x and p-x are the same single value, multiple type structure union bit
  • 14. eld with b bits member : b Operators (grouped by precedence) structure member operator name.member structure pointer pointer-member increment, decrement ++, -- plus, minus, logical not, bitwise not +, -, !, ~ indirection via pointer, address of object *pointer, name cast expression to type (type) expr size of an object sizeof multiply, divide, modulus (remainder) *, /, % add, subtract +, - left, right shift [bit ops] , comparisons , =, , = comparisons ==, != bitwise and bitwise exclusive or ^ bitwise or (incl) | logical and logical or || conditional expression expr1 ? expr2 : expr3 assignment operators +=, -=, *=, : : : expression evaluation separator , Unary operators, conditional expression and assignment oper- ators group right to left; all others group left to right. Flow of Control statement terminator ; block delimeters { } exit from switch, while, do, for break next iteration of while, do, for continue go to goto label label label: return value from function return expr Flow Constructions if statement if (expr) statement else if (expr) statement else statement while statement while (expr) statement for statement for (expr 1; expr2; expr3) statement do statement do statement while(expr ); switch statement switch (expr) { case const1: statement1 break; case const2: statement2 break; default: statement } ANSI Standard Libraries 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 Character Class Tests ctype.h alphanumeric? isalnum(c) alphabetic? isalpha(c) control character? iscntrl(c) decimal digit? isdigit(c) printing character (not incl space)? isgraph(c) lower case letter? islower(c) printing character (incl space)? isprint(c) printing char except space, letter, digit? ispunct(c) space, formfeed, newline, cr, tab, vtab? isspace(c) upper case letter? isupper(c) hexadecimal digit? isxdigit(c) convert to lower case? tolower(c) convert to upper case? toupper(c) String Operations string.h s,t are strings, cs,ct are constant strings length of s strlen(s) copy ct to s strcpy(s,ct) up to n chars strncpy(s,ct,n) concatenate ct after s strcat(s,ct) up to n chars strncat(s,ct,n) compare cs to ct strcmp(cs,ct) only
  • 15. rst n chars strncmp(cs,ct,n) pointer to
  • 16. rst c in cs strchr(cs,c) pointer to last c in cs strrchr(cs,c) copy n chars from ct to s memcpy(s,ct,n) copy n chars from ct to s (may overlap) memmove(s,ct,n) compare n chars of cs with ct memcmp(cs,ct,n) pointer to
  • 18. rst n chars of cs memchr(cs,c,n) put c into
  • 19. rst n chars of cs memset(s,c,n) 1 2 3
  • 20. C Reference Card (ANSI) Input/Output stdio.h Standard I/O standard input stream stdin standard output stream stdout standard error stream stderr end of
  • 21. le EOF get a character getchar() print a character putchar(chr ) print formatted data printf(format ,arg 1,: : : ) print to string s sprintf(s,format ,arg 1,: : : ) read formatted data scanf(format ,name1,: : : ) read from string s sscanf(s,format ,name1,: : : ) read line to string s ( max chars) gets(s,max) print string s puts(s) File I/O declare
  • 22. le pointer FILE *fp pointer to named
  • 23. le fopen(name,mode) modes: r (read), w (write), a (append) get a character getc(fp) write a character putc(chr ,fp) write to
  • 24. le fprintf(fp,format,arg 1,: : : ) read from
  • 26. le fclose(fp) non-zero if error ferror(fp) non-zero if EOF feof(fp) read line to string s ( max chars) fgets(s,max,fp) write string s fputs(s,fp) Codes for Formatted I/O: %-+ 0w:pmc - left justify + print with sign space print space if no sign 0 pad with leading zeros w min
  • 27. eld width p precision m conversion character: h short, l long, L long double c conversion character: d,i integer u unsigned c single char s char string f double e,E exponential o octal x,X hexadecimal p pointer n number of chars written g,G same as f or e,E depending on exponent Variable Argument Lists stdarg.h declaration of pointer to arguments va_list name; initialization of argument pointer va_start(name,lastarg) lastarg is last named parameter of the function access next unamed arg, update pointer va_arg(name,type) call before exiting function va_end(name) Standard Utility Functions stdlib.h absolute value of int n abs(n) absolute value of long n labs(n) quotient and remainder of ints n,d div(n,d) retursn structure with div_t.quot and div_t.rem quotient and remainder of longs n,d ldiv(n,d) returns structure with ldiv_t.quot and ldiv_t.rem pseudo-random integer [0,RAND_MAX] rand() set random seed to n srand(n) terminate program execution exit(status) pass string s to system for execution system(s) Conversions convert string s to double atof(s) convert string s to integer atoi(s) convert string s to long atol(s) convert pre
  • 28. x of s to double strtod(s,endp) convert pre
  • 29. x of s (base b) to long strtol(s,endp,b) same, but unsigned long strtoul(s,endp,b) Storage Allocation allocate storage malloc(size), calloc(nobj,size) change size of object realloc(pts,size) deallocate space free(ptr) Array Functions search array for key bsearch(key,array,n,size,cmp()) sort array ascending order qsort(array,n,size,cmp()) Time and Date Functions time.h processor time used by program clock() Example. clock()/CLOCKS_PER_SEC is time in seconds current calendar time time() time2-time1 in seconds (double) difftime(time2,time1) arithmetic types representing times clock_t,time_t structure type for calendar time comps tm tm_sec seconds after minute tm_min minutes after hour tm_hour hours since midnight tm_mday day of month tm_mon months since January tm_year years since 1900 tm_wday days since Sunday tm_yday days since January 1 tm_isdst Daylight Savings Time ag convert local time to calendar time mktime(tp) convert time in tp to string asctime(tp) convert calendar time in tp to local time ctime(tp) convert calendar time to GMT gmtime(tp) convert calendar time to local time localtime(tp) format date and time info strftime(s,smax,format ,tp) tp is a pointer to a structure of type tm Mathematical Functions math.h Arguments and returned values are double trig functions sin(x), cos(x), tan(x) inverse trig functions asin(x), acos(x), atan(x) arctan(y=x) atan2(y,x) hyperbolic trig functions sinh(x), cosh(x), tanh(x) exponentials logs exp(x), log(x), log10(x) exponentials logs (2 power) ldexp(x,n), frexp(x,*e) division remainder modf(x,*ip), fmod(x,y) powers pow(x,y), sqrt(x) rounding ceil(x), floor(x), fabs(x) Integer Type Limits limits.h The numbers given in parentheses are typical values for the constants on a 32-bit Unix system. CHAR_BIT bits in char (8) CHAR_MAX max value of char (127 or 255) CHAR_MIN min value of char (128 or 0) INT_MAX max value of int (+32,767) INT_MIN min value of int (32,768) LONG_MAX max value of long (+2,147,483,647) LONG_MIN min value of long (2,147,483,648) SCHAR_MAX max value of signed char (+127) SCHAR_MIN min value of signed char (128) SHRT_MAX max value of short (+32,767) SHRT_MIN min value of short (32,768) UCHAR_MAX max value of unsigned char (255) UINT_MAX max value of unsigned int (65,535) ULONG_MAX max value of unsigned long (4,294,967,295) USHRT_MAX max value of unsigned short (65,536) Float Type Limits float.h FLT_RADIX radix of exponent rep (2) FLT_ROUNDS oating point rounding mode FLT_DIG decimal digits of precision (6) FLT_EPSILON smallest x so 1:0 + x6= 1:0 (105) FLT_MANT_DIG number of digits in mantissa FLT_MAX maximum oating point number (1037) FLT_MAX_EXP maximum exponent FLT_MIN minimum oating point number (1037) FLT_MIN_EXP minimum exponent DBL_DIG decimal digits of precision (10) DBL_EPSILON smallest x so 1:0 + x6= 1:0 (109) DBL_MANT_DIG number of digits in mantissa DBL_MAX max double oating point number (1037) DBL_MAX_EXP maximum exponent DBL_MIN min double oating point number (1037) DBL_MIN_EXP minimum exponent May 1999 v1.3. Copyright c 1999 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. hjhs@math.brown.edui 4 5 6