Dont misunderstand. That is also C++. C++ is an upgrade of standard C. In other words C is also C++ but not the other way round. Try it youll se. C++ has new added librarys and features but the old ones that are used in C are also there. So technically it is C++ ^^
I’m just saying that I don’t want people to get confused by doing things the C way, instead of the proper C++ way. Because that is, in fact, what I’m trying to teach here.
Hmm, this could really help people who want to learn C++. But might I suggest you try to put each ‘chapter’ in your first post? It saves time searching for what you need, I would also make some kind of index as your tutorial becomes larger, so people can search more easily for what they need. Other than that, great tutorial so far.
Sorry I haven’t had a lot of time to put into this. I’ve been busy getting ready for college. I’ll try to finish Chapter III soon. Thanks for being patient though, and not flooding my PMs.
Im really interested in programming. Not like those fakes over there >_>.
Anyways, could anyone please tell me in detail whats the difference between “C” and “C++”. I’ve always wondered.
Also, a long time ago, my uncle had one of those HUGE books with lots of step by step tutorials on how to program via “C”. I want to learn from the book itself. Now, im worried. Would it simply be a waste of time learning the “C”?? My uncle said that there are a few differences but it should be fine.
That’s whats on my mind at the moment. Please help out.
EDIT: After the whole night studying the bloody thing, I realised that the C++ compiler won’t compile the C language so well. For example- When I compiled the final exe, and opened it via MS-DOs, it’ll “Blink”. Therefore I’m not able to read the writing.
So I went on the net and figured out that I should type:
getchar();
-After every line. Which can be a problem. I’ll simply keep it in the Cntrl+V.
Anyways, just for the guys who are learning of “C” hehe. Keep going Spunky! Go go =D
-Guzzie
What fakes?
In C you have to stick to the data types that are predefined. c++, you can make your own.
For instance, you have the four basic types of data in C int, char, float, double. Call them classes or types, what you will.
Anyway, in C++, you can use these types to create whole new types that can just be anything.
You can create a type called phone number that accepts data only in the format 111-1111111-rotflmao or whatever.
And you can even tell the compiler what the basic arithematic operaters do to your new classes. You can make it so that + appends the new digits to the old phone number like this
111-111111 + 12345 = 111-111111-12345
But you will have to tell it everything, mind you. everyt little bit. But still C++ rocks.
I didnt notice this reply before, so thats why this took so much time.
Ohh!! Thanks Vinay, I understand.
And what I meant by “Fakers” was the people who go “Yep ok lets do this” and end up doing nothing, so far, this thread is failing.
-Uchiha Sasuke
I’m trying to motivate myself to pick this up again. I wrote a bit more of Chapter III for anybody who’s interested in learning about constants. Sorry I fell out of this before. At first I got lazy, then I forgot about it. x_x
You should start the important stuff before constants.
The basics of pointers.
Pointers are rather advanced. I’d rather not get into that until later. It’s better for me to start off simple and then slowly unfold the more advanced topics.
Actually pointers have both basics and advanced stuff.
Ill send you a link to something. Maby you should bring it up in this thread.
So check your PM box later when i find it again. That will be the basic pointer stuff.
The advanced things you can cover later like how to use them in more complicated programs.
Cool. I’ll wait for it.
There are some good C++ tutorials here:
http://www.cprogramming.com/tutorial.html#c++tutorial
http://www.cplusplus.com/doc/tutorial/program_structure.html
If you’re just learning how to program, I’d personally advise learning a different, easier programming language first, like Python:
http://www.python.org/
The reason for this, is when you’re learning how to program for the first time, there’s a lot of new, programming language independent concepts you have to try and understand. It can be frustrating fighting ‘syntax errors’ you don’t really get, and other weird bugs or issues that come up in a more powerful, lower-level language like C++. Python has certain facilities and conventions that can make it altogether simpler in many ways.
The other nice thing about Python is that downloading the Windows installer from the Python website is all you need to do to get started. It includes a simple but useful IDE actually written in Python (called IDLE), as well as the Python interpreter. Also, the Python website itself has a lot of documentation (although sometimes it can seem a bit unorganized to me, compared to, say, Java’s).
C++ is a very sophisticated language, but it can also be pretty complex. If you’re having no trouble learning it, then go ahead and continue, but I personally learned BASIC first (although that’s obsolete now, and Python is just as simple, but better in many respects).
Although it might seem like a bit of a diversion if you want to code Half-Life mods, Half-Life was made over the course of years by a series of professional programmers (first id Software, then Valve). If you’re working on anything of a decent complexity, having a solid knowledge of programming will definitely help.
Just to demonstrate…
The Hello World program in Python:
print 'Hello, world!'
That’s the entire file.
And the Towers of Hanoi (which is admittedly a complicated program to introduce to beginners):
[code]
def hanoi(n, a, b, c):
if n>0:
hanoi(n-1, a, b, c)
print ‘Ring’, n, ‘moved from’, a, ‘to’, c
hanoi(n-1, b, a, c)
x = input('How many rings will your Hanoi tower have? ')
hanoi(x, ‘a’, ‘b’, ‘c’)[/code]
This obviously will not translate directly into Half-Life modding, but if you’re serious, and you find Python easier to work with as a beginner, I would recommend learning it to get a grasp on a lot of fundamentals of programming. Then, once you’ve worked through a Python tutorial or two, you can go back to C++.
Also, if anyone has any questions about Python, C/C++, or programming in general, feel free to ask.
I agree that learning a simpler language first can be better for learning how a programming language works at the core, but as mentioned earlier in this thread, that isn’t a very good idea. When it comes time to learn a more advanced language, such as C++, you’ll have to unlearn much of what you knew about the previous language in order to make the transition smoothly. It’s more work than is necessary.
Starting with C++ from the start is a better choice, because there are many tutorials out there that teach you the basics of programming so that it’s easy to understand. C++ is a complex language, yes, but it’s an easy language to learn with time and patience. It really is.
I’ve also emphasized earlier that this tutorial is not meant to teach you how to code in Half-Life, but the end result of this tutorial (if I ever finish it x_x) will help you toward that goal should you choose to pursue it. I personally started teaching myself C++ because I was bored, and it sounded like fun. Then as I was learning, people started talking to me about joining their mod teams (most of which I turn down, even today, simply because I don’t want the responsibility).
I do appreciate your contribution to this thread, but try to keep it related to C++ please. Thanks.
As far as IDEs go, I prefer Visual Studio. And for those looking for a free IDE, Microsoft offers a C++ only version of Visual Studio that you can download for free from Microsoft.
I recommended Visual Studio at the start of this thread. It’s what I like to use. Dev-C++ is good too, but there are a few things about it that I don’t like, namely how it often screws up line indenting and stuff. I like clean code. ![]()
Clean code is very important, especially if you aren’t the only one who has to read it.
I’m very picked about clean code. My ASM files are like pieces of art! haha
I usually just clean my code up so that I can read it more clearly. I usually can’t stand reading other people’s code because it’s messy or they don’t space certain things to my liking. ![]()
any more updates on this thing spunk master?
Every time I think about doing it, I slouch and shrug. I haven’t forgotten though.
Edit: Sample program added to Chapter III demonstrating constants and how they are used.