7 Fundamental
7 Fundamental
(Just enough C)
RESUME BY ISTIQOMAH
C Programming Language
The other big way that C extends its range of data types is
by means of pointers. A pointer is an integer (of some
size or other) designating the location in memory where
the real data is to be found.
int* intPtr; //intPtr is a pointer to an integer.
It is permitted to place the asterisk in the declaration
before the name rather than after the type:
int *intPtr;
int * intPtr;
You can put asterisk in all of ways. If you are asked what
type intPtr is, the answer is int* (a pointer to an int); the
asterisk is part of the name of the type of this variable.
Pointer
And:
int arr[] = {123, 456, 789};
Operators
NSString* key;
switch (tag) {
case 1: { // i.e., if tag is 1
key = @"lesson";
break;
}
case 2: { // i.e., if tag is 2
key = @"lessonSection"; break;
}
case 3: { // i.e., if tag is 3
key = @"lessonSectionPartFirstWord";
break;
}
}
Flow Control and Conditions
SomeType* oneItem;
for (oneItem in myCollection){
// ... statements ....
}
for (SomeType* oneItem in myCollection) { // ...
statements .... }
Function
1. We start with the type of value that the function returns; here, it returns an
int.
2. Then we have the name of the function, which is square.
3. Then we have parentheses, and here we place the data type and name of any
values that this function expects to receive. Here, square expects to receive
one value, an int, which we are calling i. The name i (along with its expected
data type) is a parameter; when the function is called, its value will be
supplied as an argument. If a function expects to receive more than one value,
multiple parameters in its definition are separated by a comma (and when the
function is called, the arguments supplied are likewise separated by a
comma).
4. Finally, we have curly braces containing the statements that are to be executed
when the function is called.
Function
File