C Style Guide Flashcards
Keywords 1: Variable Definition
a quantity that may be changed according to the mathematical problem
int x;
Keywords 2: Variable Declaration
x = 10;
Keywords 3. Expressions
a combination of operands and operators
A+B;
A*B;
A==B:
Keywords 4. Operators
+, -, *, /, %, ++, –,
Relational Operators: ==, !=, >, > >=, <=,
Logical Operators: &&, ||, !(A &&B)
https://www.tutorialspoint.com/cprogramming/c_operators.htm
Keywords 5. Precedence table
https://www.cs.uic.edu/~i109/Notes/COperatorPrecedenceTable.pdf
operators will be performed in a different order of precedence, according to the precedence table.
Keywords 6. Sequence points
https://learn.microsoft.com/en-us/cpp/c-language/c-sequence-points?view=msvc-170
A point where all of the previous expressions must have been completed before continueing with the following expressions
Keywords 7. bits/bytes/wchar
wide char, meant to store UTF standard characters
bit, 1 and 0.
byte, 8 bits.
Keywords 8. Binary/octal/hexadecimal/decimal
don’t make me do it
Keywords 9. ASCII table
https://www.asciitable.com/
American Standard Code for Information Interchange,
Keywords 10. UTF
Unicode Transformation Format.
UTF-8: 9bit unicode conversion format.
UTF 65 = A
UTF 66 = B
etc
Keywords 11. Escape characters
backslash followed by uh, something.
https://www.ibm.com/docs/en/rdfi/9.6.0?topic=set-escape-sequences
\n creates a new line
\a creates an alert(?)
etc.
Expressions:
; - separator
int a; variable definition
void foo(int); function declaration
if(a > b){/* . . . /}; flow control statement, (a>b is an expression)
return, continue, break, for, do and while; flow control statements
void bar(void){/ . . . /}; function definition
struct definition: X{/ . . . */}
Alias Definition: typedef struct X X_t
Parts of Expressions
Type: int*, char, const, long, etc. including whether it is an l-value or non l-value
(l-value: expression representing a persistent memory location. can be accessed after the expression has been evaluated. & operator can only be used on l-value expressions)
Value: value of the expression
Side effect: something that can happen because of going through the expression at run time, but not needed in calculating the result.
Evaluation process: NOT a side effect.
Examples of Expressions
85
integer literal, type: non l-value int, value: 85
‘a’
character literal. Type: non l-value int
“abc”
String literal. Type: l-value array of 4 characters. value: when converted to a char*, value is the address of the first character
x
Variable, Type: l-value expression of the type x, value: value that x was initialized or assigned to.
-Evaluation process:
Sequence Points
Sequence Point: “A point in the code that guarentees the order of side effects”
Sequence Points: &&, ||, ? and ,
Sequence Point: ;
function call has two sequence points: one before it is called, and one after it returns. (must complete all side-effects preceding the parameter input, and return value.)