text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
>> And why was that?
1,205.99
1.17
What was the code that we wrote before that ensured that the cursor would
1,207.16
5.24
go on the next line?
1,212.4
2.482
Funny thing about a computer is it's only going
1,214.882
1.958
to do literally what you tell it to do.
1,216.84
1.73
>> So if you tell it to printf hello, comma, space, world, close quote,
1,218.57
7.48
it's literally only going to print those characters.
1,226.05
3.04
But I had this special character at the end, recall, backslash n.
1,229.09
2.89
And that's what ensured that the character went
1,231.98
2.25
to the next line of the screen.
1,234.23
2.34
>> In fact, let me go and do this.
1,236.57
1.527
Let me go ahead and delete this.
1,238.097
1.333
Now, notice that the top of my screen there's
1,239.43
1.75
a little red light in the tab indicating,
1,241.18
1.71
hey, you've not saved your file.
1,242.89
2.157
So I'm going to go ahead with control S or command S, save the file.
1,245.047
2.833
Now it goes-- went for a moment-- green.
1,247.88
3.25
And now it's back to just being a close icon.
1,251.13
2.63
>> If I now run clanghello.c again, Enter, dot slash, a.out, Enter,
1,253.76
8.1
you'll see that it still worked.
1,261.86
2.25
But it's arguably a little buggy.
1,264.11
1.91
Right now, my prompt-- workspace, and then that dollar sign,
1,266.02
2.694
and then my actual prompt-- is all on the same line.
1,268.714
2.166
So this certainly an aesthetic bug, even if it's not really a logical bug.
1,270.88
3.66
>> So I'm going to undo what I just did.
1,274.54
1.71
I'm going to rerun a.out.
1,276.25
2.31
Notice I've added the newline character back.
1,278.56
4.15
I've saved the file.
1,282.71
1.57
>> So I'm going to rerun a.out, and-- dammit, a bug, a bug meaning mistake.
1,284.28
7.35
So the bug is that even though I added the backslash n there,
1,291.63
3.39
re-saved, re-ran the program, the behavior was the same.
1,295.02
6.16
Why would that be?
1,301.18
1.46
>> I'm missing a step, right?
1,302.64
1.27
That key step earlier was that you have to-- when you change your source code,
1,303.91
3.71
it turns out also run it through the compiler
1,307.62
1.99
again so you get new machine code.
1,309.61
1.492
And the machine code, the zeros and ones,
1,311.102
1.708
are going to be almost identical, but not perfectly so, because we need,
1,312.81
3.45
of course, that new line.
1,316.26
1.25
>> So to fix this, I'm going to need to rerun clanghello.c, enter, dot
1,317.51
5.13
slash, a.out.
1,322.64
1.16
And now, hello world is back to where I expect it to be.
1,323.8
4.602
So this is all fine and good.
1,328.402
1.208
But a.out is a pretty stupid name for a program, even though it happens to be,
1,329.61
3.54
for historical reasons, the default-- meaning assembly outputs.
1,333.15
3.38
>> But let me go ahead here and do this differently.
1,336.53
4.25
I want my hello world program to actually be called hello.
1,340.78
3.98
So if it were an icon on my desktop, it wouldn't be a.out.
1,344.76
3.56
It would be called hello.
1,348.32
1.41
>> So to do this, it turns out that Clang, like many programs,
1,349.73
3.93
supports command line arguments, or flags, or switches,
1,353.66
4.32
which simply influence its behavior.
1,357.98
1.62
Specifically, Clang supports a dash o flag, which then takes a second word.
1,359.6
5.56
In this case, I'll arbitrarily, but reasonably, call it hello.
1,365.16
3.03
But I could call it anything I want, except a.out, which
1,368.19
2.52
would be rather besides the point.
1,370.71
1.68
>> And then just specify the name of the file I do want to compile.
1,372.39
3.25
So now even though at the beginning of the command I still have Clang,
1,375.64
3.55
at the end of the command I still have the filename,
1,379.19
2.22
I now have these command line arguments, these flags that are saying,
1,381.41
4.11
oh, by the way, output-o, a file called hello, not the default a.out.
1,385.52
5.66
>> So if I hit Enter now, nothing seems to have happened.
1,391.18
2.63
And, yet, now I can do dot slash hello.
1,393.81
4.09
So it's the same program.
1,397.9
1.189
The zeros and ones are identical at the end of the day.
1,399.089
2.291
>> But they're in two different files-- a.out,
1,401.38
2.83
which is the first version and just foolishly named,
1,404.21
2.28
and now hello, which is a much more compelling name for a program.
1,406.49
3.76
But, honestly, I am never going to remember this again,
1,410.25
2.945
and again, and again.
1,413.195
0.875
And, actually, as we write more complicated programs,
1,414.07
2.341
the commands you're going to have to write
1,416.411
1.749
are going to get even more complicated still.
1,418.16
2.76
>> And so not to worry.
1,420.92
1.02
It turns out that humans before us have realized they too
1,421.94
4.28
had this exact same problem.
1,426.22
1.31
They too did not enjoy having to type fairly long, arcane commands,
1,427.53
3.37
let alone remember them.
1,430.9
1.3
And so humans before us have made other programs that make it easier
1,432.2
3.87
to compile your software.
1,436.07
1.6
>> And, indeed, one such program is called Make.
1,437.67
3.939
So I'm going to go ahead and do this.
1,441.609
1.541
I'm going to undo everything I just did in the following way.
1,443.15
2.541
Let me type LS.
1,445.691
1.999
And you'll notice three things-- a.out, and a star, hello
1,447.69
3.29
and a star, and hello.c.
1,450.98
1.83
Hopefully, this should be a little intuitive,
1,452.81
1.92
insofar as earlier there was nothing in this workspace.
1,454.73
3.49
There was nothing that I had created until we started class.
1,458.22
3.02
>> And I created hello.c.
1,461.24
1.6
I then compiled it, and called it a.out.
1,462.84
1.704
And then I compiled it again slightly differently and called it hello.
1,464.544
2.916
So I have three files in this directory, in this folder called Workspace.
1,467.46
5.37
Now, I can see that as well if I zoom out actually.
1,472.83
2.175
>> If I zoom out here and look at that top right hand
1,475.005
2.525
corner, as promised the left hand side of your screen
1,477.53
2.41
is always going to show you what's in your account, what's
1,479.94
3.05
inside of CS50 IDE.
1,482.99
1.8
And there is three files there.
1,484.79
1.89
>> So I want to get rid of a.out and hello.
1,486.68
2.39