Introduction to C Flashcards
What is C?
C is a weakly, statically-typed compiled language
Define statically typed:
Variable types are known at compile time
Define weakly-typed:
Relaxed approach to typing, for example variables can be implicitly converted to a different type
Define compiled language:
Build assembly code and run it
Is C Object Oriented Programming?
NO!
How is memory management handled in C?
Memory management is handled by the programmer. Memory space must be managed and monitored.
What is a preprocessor?
Passes through the code first and makes a number of substitutions with the directives pointed at (find and replace)
What are the parameters of the main function?
- int argc (Number of program arguments)
- char* argv[] (array of program arguments)
What is a declaration of definition of a variable?
Announcing its properties (type) and setting aside memory, but does not initialise it.
What happens if a variable is not explicitly set?
Whatever was last stored in that memory space will be stored in that variable, until redefined.
Can variables be redeclared in the local scope if the are defined in the global scope?
Variables can be redeclared in the local scope if it’s already defined in the global scope.
Can variables be redefined in the global scope?
It cannot be redefined in the global scope if it already exists in there.
What should we set used variables to after we don’t need them?
It is good practise to set the variables to 0/null after they’ve been used as there is no garbage collection in C unlike Java.
In C what is static (in the global scope)?
A static in the global scope is a variable or function that is for the private use of functions in the declaring file only
In C what is static (in the local scope)?
In the local scope a static variable is not destroyed at the end of the scope, the next time the scope is called, the previously set value will be there