Cheatography
https://cheatography.com
A quick reference for my class: CSCV 352 System Programming + Unix
This is a draft cheat sheet. It is a work in progress and is not finished yet.
C Program Structure
/* multi-line */ |
comment |
// single-line |
comment |
preprocessing commands |
includes header files, define constants and enum |
global declarations |
declare global variables |
prototype functions |
declare functions under main |
int main (void) { |
start of program execution |
local declarations; executable statements; |
the program |
return 0; } |
end of program |
user function() { function definition; } |
user defined functions referenced in main |
C Data Keywords
Original K&R Keywords |
C90 K&R Keywords |
C99 Keywords |
int |
signed |
_Bool |
long |
void |
_Complex |
short |
|
_Imaginary |
unsigned |
char |
float |
double |
|
|
scanf() Specifiers
%c |
character |
%d |
signed decimal integer |
%e, %f, %g, %aC99 |
floating-point number |
%E, %F, %G, %AC99 |
floating-point number |
%i |
signed decimal integer |
%o |
signed octal integer |
%p |
ponteran address |
%s |
string1 |
%u |
unsigned decimal integer |
%x, %X |
signed hexadecimal integer |
1 begins with first non-whitespace character and ends with the next whitespace character
printf() Specifiers
%a |
floating-point number, hexadecimal digit and P-nonation C99/C11 |
%A |
floating-point number, hexadecimal digit and P-nonation C99/C11 |
%c |
single character |
%d |
signed decimal integer |
%e |
floating-point number, exponent is less than -4 or greater than or equal to the precision |
%E |
floating-point number, exponent is less than -4 or greater than or equal to the precision |
%f |
floating-point number, decimal notation |
%g |
use %f or %e, depending on the value |
%G |
use %f or %E, depending on value |
%i |
signed decimal integer same as %d |
%o |
unsigned octal integer |
%p |
pointer |
%s |
character string |
%u |
unsigned decimal integer |
%x |
unsigned hex integer, using hex digits 0f |
%X |
unsigned hex integer, using hex digits 0F |
%% |
prints a % sign |
|