summaryrefslogtreecommitdiff
path: root/handouts/trial-section3
blob: 1cbb34fb4d3338c0043fde7f17db74859db9e0c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
- - - - - - ---=[Urbana Electronics & Programming Summer Program]=--- - - - - -
[Trial Session 2/23/2018]
TOPIC 1 - Linux System Maintenance

[Section 3, Nano]---------------------------------------------------------------
	
	First off, in order to get this file you have to download it off the
internet. The command for that is "wget". Type:

	wget http://uepsp.xyz/handouts/trial-section3

	Now, if you type "ls" you should be able to see "trial-section3"

	If you want to just read the file, use the "less" command. This opens a
file and let's you scroll through it. It's called less because there used to be
a command called "more" that it replaced.

	less trial-section3

	To exit, press q.

	Ok so you can look at a file, but what about edit it? That's where a
text edit comes in. A text editor lets you, wait for it, edit text. The one
you'll be using today is called nano. To make a new file called hello.c simply
type:

	nano hello.c

	hello.c didn't exist before, but now nano has created this file.

	You can now edit the text file as you would normally edit text anywher
else. To exit, press "CTRL X". If you've made any changes it should ask "Save
modified buffer?...", press y to save. Then it should show the name of the file
you're editing, press enter.

	Ok so now you know nano!
[Section 4, GCC]----------------------------------------------------------------

	Ok now to the juicy bits, programming. You're going to learn the C
language. C was one of the earliest high level programming languages, and is one
that many other languages base their syntax off of. If you don't what that means
don't worry, it just means that if you learn C, every other language will seem
like a breeze.

	Many people say tha C is too hard, but after walking you through this
example you'll know that C is a breeze!.

	Here's what you're finished program should look like:

#include<stdio.h>
int main (int argc, char *argv[]) {
	printf("hi ducky!\n");
	return 0;
}

	Now let's break that down. First off you have "#include<stdio.h>". This
is called a preprocessor directive, it's something that's technically a part of
the code, and gets processed by the "preprocessor" before the code is compiled.
Preprocessor directives start with a # and usually 

	"Preprocessor", "Compiled", what do all these words mean? Well, when you
write code, that's in what's called a Human Readable Language, but that isn't
what your computer runs. Computers run something called "machine code", which
isn't pretty to look at and is way more complicated to this. To create "machine
code" that does what want, you write code in a programming language, in this
case C, and then compile that code to create a "binary executable". A binary
executable just means that it's the file containing the code that your computer
is going to run, a program so to speak.

	But before the compiler can do anyth