1/42
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
how do you know if a line in your source code is a preprocessor directive?
begins with a "#"
ex. #include
what does "compile" do?
turn the source code to an object code
what does "link" do?
turn the object code to an executable
what are the format specifiers?
begin with % and are used as placeholders to define the format and type of data to be printed
format specifier to print base 10 signed int
%d
format specifier to print base 10 unsigned int
%u
format specifier to print floating point values
%f
format specifier to print pointers
%p
format specifier to print hexadecimals
%x
format specifier to print characters
%c
format specifier to print strings
%s
valid names for a makefile
makefile
Makefile
default target
first target defined in the makefile
how can target dependencies be specified?
after the target name and the colon(:), specify a list of space-seperated dependencies
how are strings represented in C
data type is just an array of characters
diff b/w array and array of char
array of char to quaify as a string in C, the special null charcter (\0) must be the last charcter
diff b/w array and array of char
null character is used to indicate the end of the string
declare a pointer
how to obtain the memory of address of variable?
-use the "address of" operator &
-ptr = &x;
how do you retrieve the data value that a pointer points to? how do you update the data value using that pointer?
- use dereference operator*
- int y = *ptr;
- *ptr = 10
6 phases of a C program
1. editing in the editor
2. preprocess - processes the code
3. compile - compiler created the object file and stores it in the dicks
4. link - where executable files are created from object
5. load - where the code is put into a memory disk by the loader
6. execute: where the code is run and executed
compile and linking a c program
use command $ gcc -o filename filename.c
running a c program
use command $ ./filename
make utility
make is used in c and is incorporated in makefile
makefiles with variables
adding variables makes it very useful for multiple files
-Wall -pedantic-error flags
catch potential bugs with code
fundamental data types
char, int, float, double
data types modifiers that can combine with earlier types
signed, unsigned, short, long
signed
ability to look at negative numbers
0(+)
1(-)
char size
1 byte
unsigned char
8 zeros
sizeOf()
to check the size
& bitwise
compares each bit and does AND
| bitwise
compare each bit and does OR
^ bitwise
compares each bit and does XOR
~ bitwise
NOT
bits are flipped
<< left shift
shifts bits to left
>> right shift
shifts bits to the right
bitwise operators
- manipulate individual bits within a variable
- helps use less memory
arrays
Series of elements of the same type placed adjacently and can be referenced by indexes in a unique identifier
arrow operator
dereference operator which can be used with pointers to structs and can direct access the members
stack
used for mainly static memory location
heap
is used for dynamic memory allocation for storing objects and data structures that require a longer life