- Integer types:
- char
- short
- int
- long
- char
- Floating point types:
- float
- double
- long double
- float
Char
- 1 byte long
- char<= short<=int<=long
- denote characters in single quotes
- \0 is a null character
- char *b = "TEST";
- is a string writer (assumption)
- is a string writer (assumption)
- EOF
- Reads as -1
- Which is an array of ones
- Which is an array of ones
- getchar() reads a byte of unsigned chars and stores 4 bytes to represent them
- the promotion to int is done as a signed char
- This is because of things like EOF
- the promotion to int is done as a signed char
- A signed char
- Fills the other bytes with the first bit of the signed char
- If it is signed and starts with 0
- It is non negative
- It is non negative
- If it starts with 1
- It is a negative number
- It is a negative number
- Fills the other bytes with the first bit of the signed char
- An unsigned
- Does not fill the other 3 bytes with the first bit but with all 0's when promoted to an int
- Does not fill the other 3 bytes with the first bit but with all 0's when promoted to an int
Declarations
- when you declare a variable in C it is visible throughout the score of the brackets that it is withheld
- if you want a variable to be visible throughout a program put it above the main
- to make one variable local to a file use the word 'static'
String
- an array of char
- there is no 'String' in C
Arrays
- to declare an array in C
- use type name[size]
- example: int number[10]
- example: int number[10]
- you can initialize an array w/o a specified size
- char s[] = {'h','e','l','l','o','\0', 'q'}
- printf("%s /n", s}
- returns 'hello'
- note there is no q, that is because null character was before it
- note there is no q, that is because null character was before it
- char s[] = {'h','e','l','l','o','\0', 'q'}
printF
- %d prints integers
- %s prints char characters
- Prints until it finds a null character
- Null character is \0
- Prints until it finds a null character
- %p prints the address
Console
- Od –cb filename
- Describes a file in bits
- Describes a file in bits
No comments:
Post a Comment