This is a for loop, it loops with index
from 0
to argc - 1
.
I think you are going a bit too fast for me.
Yes, sorry, let’s break it down: the for loop has two parts, the header between
the parentheses (
and )
, and the body between the braces {
and }
.
The header itself has three parts, separated by semicolons:
- initial setup, in this case
int index = 0
declares a variable calledindex
of typeint
, with initial value zero; - each time before running the body, it runs
index < argc
, and if it is true, then it runs the body. Hence the loop can run withindex = 0, 1, 2, ..., argc - 1
, but not withindex = argc
as the condition will be false. - each time after running the body, it runs
index++
, which is shorthand forindex += 1
, itself shorthand forindex = index + 1
. This is whyindex
is a variable, it can change.
Note, that a single equal sign as in index = index + 1
is actually
assignment, not checking for equality. To check for equality you use two
consecutive equal signs, such as index == index + 1
, which is of course
false.
🐶
This is your first context line, the space instead of the plus means it is unchanged in this commit.
🐱
And presumably the minus below instead of the space or plus means that line is removed?
🐶
Correct, and note this file now has two line numbers, the one on the left hand side is the old line numbers, and the one on the right hand side is the new line numbers.
Also, the hunk header is now different too. It means that the hunk has 6 lines, starting from line 1 of the old file, and 7 lines starting from line 1 of the new file. This all lines up with the line numbers.