chevron_left chevron_right
Login Register invert_colors photo_library


Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


Tutorial Introduction to C Programming [Part 1: Setup and terms] filter_list
Author
Message
Introduction to C Programming [Part 1: Setup and terms] #1
So you want to learn how to program. Well, I think C is a great place. It is low level, but at the same time easy to understand once you've gotten the hang of it. Just a forewarning, I won't go into extreme detail in this series, it is just to get you comfortable enough to learn the rest on your own.

So, part 1. Let's get you all set up.

For the purpose of this tutorial, you will need to be running a linux system. I recommend Debian, and I will assume you are using Debian (or a debian-based system like ubuntu, KNOPPIX, DSL, etc).

Let's get started. This step MUST be followed EXACTLY. It will be redundant in most scenarios, but just in case.

You need to satisfy the following requirements to continue:
  1. Connect to the internet
  2. Open a TTY (CTL+ALT+F3 will get you one) or terminal emulator (I would use xterm if you have it)
  3. Root access (run sudo -s)

Alright, now let's get a list of the things we need:
  1. Text editor (we will use nano)
  2. C Compiler

Pretty simple. Let's install those things now.
Code:
apt-get update
apt-get install nano gcc

Assuming it installed correctly, you can go ahead and run exit to get back to a normal terminal.



Terms:
Code:
Terminal - a TTY or terminal emulator
Editor - GNU Nano (our text editor)
Compiler - gcc (C compiler, turns our code into binaries)



How to use nano:
from a command line, type
Code:
nano <filename goes here>
It will open up the file, you can use the keyboard to navigate and edit. Here is a list of key combinations you should know:
Code:
^W - Find
^\ - Find/Replace
^O - Write file
^X - Exit (write if needed before exit)
^- - Go to line
Of course, ^ means control+



And there you have it, you're ready to start programming. In the next part I will start to teach you C from the ground up (the hard way, be afraid)

Reply

RE: Introduction to C Programming [Part 1: Setup and terms] #2
Do people still type code into nano? I'd only use that for minor changes as opposed to building programs. I'd much rather build programs in sublime, and if tty is a requirement vim, with highlighting as you can also click around on the terminal instead of arrow keys.
#MakeSinisterlySexyAgain

Reply

RE: Introduction to C Programming [Part 1: Setup and terms] #3
(01-12-2015, 09:50 PM)Adorapuff Wrote: Do people still type code into nano? I'd only use that for minor changes as opposed to building programs. I'd much rather build programs in sublime, and if tty is a requirement vim, with highlighting as you can also click around on the terminal instead of arrow keys.

No mouse usage in a TTY. Yes though, I use nano for nearly everything. Don't want to explain all of the vi commands today. Sublime is good, but it requires you to have also installed X11, and I REALLY don't want to deal with that nonsense.

Reply

RE: Introduction to C Programming [Part 1: Setup and terms] #4
(01-12-2015, 10:03 PM)phyrrus9 Wrote: No mouse usage in a TTY. Yes though, I use nano for nearly everything. Don't want to explain all of the vi commands today. Sublime is good, but it requires you to have also installed X11, and I REALLY don't want to deal with that nonsense.

So you only ever write code in a terminal only environment and since you don't want to deal with xorg you are currently browsing and posting on SL using a text-based browser such as Lynx?

That's pretty badass man, can I have a picture of your beard?

Reply

RE: Introduction to C Programming [Part 1: Setup and terms] #5
(01-12-2015, 11:13 PM)blackhatcat Wrote: So you only ever write code in a terminal only environment and since you don't want to deal with xorg you are currently browsing and posting on SL using a text-based browser such as Lynx?

That's pretty badass man, can I have a picture of your beard?

Spoiler:
[Image: rSwOeY5l.jpg]

I have X set up on my machines, but I dont see a point in teaching you how to use it.

Reply

RE: Introduction to C Programming [Part 1: Setup and terms] #6
This thread is rather remedial and does not make sense as a standalone tutorial, especially in the C/C++ coding section as there is little mention of coding. It would make more sense to just open whatever the next tutorial is with a mention of opening/creating a file in the user's favorite text editor. Nano is far from ideal for most programming and we would hate for users to be taught bad habits. It would seem the only Relevance to C is:

(01-12-2015, 09:47 PM)phyrrus9 Wrote: apt-get update
apt-get install nano gcc

Which again, would make sense either as a foreground to the tutorial or as a reply to someone who is confused about how to use apt-get. It does not make sense to pigeonhole a tutorial of C programming like this to one distro of one OS using one specific editor. You will alienate more people than you will attract with such stringency.

Reply

RE: Introduction to C Programming [Part 1: Setup and terms] #7
(01-13-2015, 03:55 AM)Arthur Curry Wrote: This thread is rather remedial and does not make sense as a standalone tutorial, especially in the C/C++ coding section as there is little mention of coding. It would make more sense to just open whatever the next tutorial is with a mention of opening/creating a file in the user's favorite text editor. Nano is far from ideal for most programming and we would hate for users to be taught bad habits. It would seem the only Relevance to C is:


Which again, would make sense either as a foreground to the tutorial or as a reply to someone who is confused about how to use apt-get. It does not make sense to pigeonhole a tutorial of C programming like this to one distro of one OS using one specific editor. You will alienate more people than you will attract with such stringency.

Much better. You may suggest an edit to the original thread. But note it is a multi part tutorial. Can't expect beginners to be expected to use a magnetized needle and a steady hand.

Don't see how using nano is a bad habbit, but that can be your opinion if you wish.

Reply

RE: Introduction to C Programming [Part 1: Setup and terms] #8
Writing my C code into the simple text editor that OSX gave me. I'm new to C and got only the basics off till now. Also I'm not that confident to all the "special" editors. I don't know why people say that other editors are better then some others. Cause of the full screen mode, the customization or other stuff? Would be great to know what u guys think about the common editors. Maybe my next program would be written with one of this special editors.

I personally don't like IDE's that much cause I think their helping beginners too much. Later when ur good at a language u can use them for faster progress. Thats my opinion. Whats urs?

Hope to read the next part of ur C tutorial cause I'm rly interested bout it even if u just, like u told us above, cover the basics. Im looking for good C tutorials and these threads could be very nice.

/coax
______________________________________________________________________________

"There are only 10 types of people in the world: Those who understand binary, and those who don't."

Reply

RE: Introduction to C Programming [Part 1: Setup and terms] #9
(01-12-2015, 09:50 PM)Adorapuff Wrote: Do people still type code into nano? I'd only use that for minor changes as opposed to building programs. I'd much rather build programs in sublime, and if tty is a requirement vim, with highlighting as you can also click around on the terminal instead of arrow keys.

Meh, I don't know: I kinda like nano.

Reply

RE: Introduction to C Programming [Part 1: Setup and terms] #10
Are you planing any Java or Python tutorials in the future it will greatly assist my studies. Thanks
[Image: master645.png]

Life before death, strength before weakness, journey before destination.” ― The Way of Kings by Brandon Sanderson

Reply






Users browsing this thread: 1 Guest(s)