You are looking at lesson 8. Your place is still lesson 9, task 1: Strings.
An address (&), a pointer and dereferencing (*), NULL, passing by pointer, an array as a pointer to its first element and pointer arithmetic.
A pointer is a variable whose value is the address of another variable.
int x = 5;
int *p = &x; /* p is a pointer to int; it holds the address of x */
*p = 7; /* writes 7 where p points, that is, into x */
int *p is a pointer to int. A star in a declaration means "pointer".&x is the address, *p is the variable p points to (dereferencing). A star in an expression means "where it points".int * points only to an int.int *r = NULL; is a pointer that points nowhere. Before using *r, check r != NULL. Dereferencing NULL crashes the program: in CLion on Windows Process finished with exit code -1073741819 (0xC0000005), on Linux Segmentation fault.
Worse still is an uninitialised pointer: int *p; *p = 5; writes anywhere. Luckily the compiler often catches it: 'p' is used uninitialized.
In topic 5 a function received copies: x = x * 2 inside the function doesn't change the caller's variable. For a function to change the caller's variable, it is given the address:
void swap(int *a, int *b) {
int tmp = *a;
*a = *b;
*b = tmp;
}
swap(&x, &y);
This way a function can also "return" several results: min_max(t, n, &min, &max) writes both.
An array's name in an expression turns into a pointer to its first box: int *q = t; is the same as &t[0]. And:
q + 2 is the address two boxes further (not two bytes: the compiler multiplies by sizeof(int));*(q + 2) and q[2] are the same; t[i] really means *(t + i).So the parameter int t[] is really int *t. That explains two things from topic 6: why a function can change an array (it gets the address, not a copy) and why sizeof t inside a function gives the size of a pointer. const int *t means you can't change anything through this pointer.
A function's local variable disappears when the function ends, so you can't return its address:
int *bad(void) {
int x = 5;
return &x; /* error: function returns address of local variable */
}
Each one ticks itself when you do it.
All six done. You know your way around.
It is laid out like CLion: the same panels in the same places. This tour shows each one, and you can reopen it any time with Tour.
Switches the left panel: Lesson plan, Project files, Changes. Click the active icon again to hide the panel.
In CLion: the tool window bar runs down the left edge, too.
This part is not on this task: it appears when a task needs it.
Every task in this lesson. Now marks your place. Clicking a task only lets you look; it never moves your place. Project files and Changes open here too.
In CLion: this spot holds the Project view (the file tree).
This part is not on this task: it appears when a task needs it.
Opens the file for your task by itself. A tab appears for each file the step opens. The breadcrumbs above the code show the folder.
In CLion: the same editor tabs and breadcrumbs.
This part is not on this task: it appears when a task needs it.
Diff shows what changed, like git diff: red is the old code, green the new.
In CLion: the diff view in the Commit window looks the same.
This part is not on this task: it appears when a task needs it.
Terminal for build commands, Database to see your tables. They open by themselves when a task needs them. Drag the top edge to resize.
In CLion: Terminal, and the Database tool window.
This part is not on this task: it appears when a task needs it.
What to do now, right above the code, so you never miss it. Numbered notes in the code explain the important lines. Details shows what you should see and a hint.
In CLion: no equivalent: this is your lecturer's guide.
This part is not on this task: it appears when a task needs it.
Done is the only button that moves you forward. Look back lets you review without losing your place.
This part is not on this task: it appears when a task needs it.
Guided, Focus code or Floating. You can drag the panel edges too. Your layout is remembered for next time.
In CLion: you can also rearrange and hide tool windows.
This part is not on this task: it appears when a task needs it.
Six small missions. Each one ticks itself when you do it, so you know you have found everything.