C Programming Tutorial
I have started a series of on-going tutorial files for the C programming language. As C++ is a superset of C, I will do this series after I get somewhat into the C tutorials, say at least as far as the basics of Windowed application development as compared to console application programming.
So far I have just about finished the bit describin in detail why one should bother learning programming, so I have a fair bit to go yet. I hope to have the introductory stuff that introduces the basic stuff one needs to know before they fully understand the most basic of coding (such as what a function is etc), within a couple of days so that I can get on to the more interesting stuff, ie explaining how to actually code stuff.
I would appreciate it if any of the C/C++ programmers would there would let me know what programming concepts you have the most problems understanding/or have trouble with before so that I might be able to focus on areas that many people have found difficult... your help would be greatly appreciated, and will result in a more useful series of tutorials.
EDIT: The first part of the tutorial has been delayed, and the first three parts will be released all in one one the following Tuesday. Part One introduces Programming Concepts and is relatively short. Part Two is about the basics of Function Calling, Part Three is about Data Types and Variables, and their output.
The source code examples will be out on Thursday.
Note, the days specified are in New Zealand time
So far I have just about finished the bit describin in detail why one should bother learning programming, so I have a fair bit to go yet. I hope to have the introductory stuff that introduces the basic stuff one needs to know before they fully understand the most basic of coding (such as what a function is etc), within a couple of days so that I can get on to the more interesting stuff, ie explaining how to actually code stuff.
I would appreciate it if any of the C/C++ programmers would there would let me know what programming concepts you have the most problems understanding/or have trouble with before so that I might be able to focus on areas that many people have found difficult... your help would be greatly appreciated, and will result in a more useful series of tutorials.
EDIT: The first part of the tutorial has been delayed, and the first three parts will be released all in one one the following Tuesday. Part One introduces Programming Concepts and is relatively short. Part Two is about the basics of Function Calling, Part Three is about Data Types and Variables, and their output.
The source code examples will be out on Thursday.
Note, the days specified are in New Zealand time
Sorry I was expecting a post like "Yo does n e 1 kno a good ++c tutorial" that we get every two weeks or so.
Sorry for the randomness but you know me...
Sorry for the randomness but you know me...
LOL...oh yes, well I would think on second thought that many people will mistake what this thread is about. Not the best subject title I admit .
But if anyone does want the link for any good online C/C++ tutorials (eventuall I will provide a link so people can download my tutorials), they might want to try these:
For Linux related C stuff:
Here
C and C++ stuff:
Here
A decent C Board:
Here
But if anyone does want the link for any good online C/C++ tutorials (eventuall I will provide a link so people can download my tutorials), they might want to try these:
For Linux related C stuff:
Here
C and C++ stuff:
Here
A decent C Board:
Here
I'll be watching the Board with hawk-eyes for that tutorial, binarycode. I'm hoping that i find it very, very, very simple - like explaining it to a real-life idiot. An idiot's guide. That's me - someone who knows only how to use the computer as word processor.
It's so much like learning a new language...so it's quite difficult. Compounded by some kind of mathematics that I could no longer remember. Can u make it simple enough also by giving consideration to one who can only do additions, multiplication, etc?
It's so much like learning a new language...so it's quite difficult. Compounded by some kind of mathematics that I could no longer remember. Can u make it simple enough also by giving consideration to one who can only do additions, multiplication, etc?
And oh, it's quite a challenge to simplify the most complex of things...takes a huge amount of creative intelligence. Somewhat like explaining how and why a lightbulb works to a kindergartener using a different language other than her own.
and you shall also be able to find some tutorials on www.about.com
Dont worry I fully intend to make this all as simple as I can while still gradually introducing critical concepts. Advanced knowledge is heirarchial, and this is how I intend to handle the tutorials, starting at a level which assumes no programming expereince and little knowledge of computers, and slowly building up in small, regular (I intend to release installments at least once a week) bits that allow even the most inexpereinced student to eventually become a proficient programmer. In fact, it will be really simple I hope, sort of like those "Dummy" books, but more useful.
As for the level of mathematics involved, well at points I will be dealing with mathematical subject matter, you cannot totally avoid using mathematics in alot of real world programming tasks. But the mathmatical stuff I will be presenting will be explained as well as possible and I will not use more maths than I need to, I appreciate that not all of my target audeince likes maths as much as I do.
Most the of the maths stuff will be addition and stuff, or stuff where you can learn programming commands and have the computer handle the more difficult calculations. More advanced topics might involve more complicated mathematical subject matter, but you could probably endure not mastering this unless you want to be a proffessional programmer.
As for the level of mathematics involved, well at points I will be dealing with mathematical subject matter, you cannot totally avoid using mathematics in alot of real world programming tasks. But the mathmatical stuff I will be presenting will be explained as well as possible and I will not use more maths than I need to, I appreciate that not all of my target audeince likes maths as much as I do.
Most the of the maths stuff will be addition and stuff, or stuff where you can learn programming commands and have the computer handle the more difficult calculations. More advanced topics might involve more complicated mathematical subject matter, but you could probably endure not mastering this unless you want to be a proffessional programmer.
I have looked and there are indeed a few decent C/C++ tutorials on here as it turns out. But my tutorial series has the advantages that you can more easily save it all on your hard drive due to the fact that it will come in two forms: Linked html files, or text files (you will be able to choose which one at download time).
However, I definetly encourage using online resources to supplement my tutorails if you do use them, as no single textbook or tutorial can ever approach the subject matter from all angles, in ways that fully cater for all different learning styles/ability levels etc.
However, I definetly encourage using online resources to supplement my tutorails if you do use them, as no single textbook or tutorial can ever approach the subject matter from all angles, in ways that fully cater for all different learning styles/ability levels etc.
How about putting tests in it which tests everything you learned so far? I'm often doing that with my tutorials...
As I probably told you before, I learned Pascal at school, and this year I'm trying to learn C. In Pascal, I had a special data type called "string". Instead of typing
char s[256];
I was typing
s: string;(in pascal, when I declare a data I put the varaible first)
There was a function called val:
void val(string s, int x, int err);
If the chars contained by s were digits, then x would become the number value contained in s. If not, the err varaible would indicate the position of the first non-digit char.
Is anything similar in C? Can you indicate me a good tutorials about strings, in C?
char s[256];
I was typing
s: string;(in pascal, when I declare a data I put the varaible first)
There was a function called val:
void val(string s, int x, int err);
If the chars contained by s were digits, then x would become the number value contained in s. If not, the err varaible would indicate the position of the first non-digit char.
Is anything similar in C? Can you indicate me a good tutorials about strings, in C?
I intend to do this, in fact I will offer two sets of tests, easier tests, and tests for more capable students that might find the other simple test a little TOO easy.
You link to the C++ tutorial is not right... it has dinknetwork.com in front...
C++ Language Tutorial
Weird synchronicity of life... I have just started working through this tutorial to try and learn C++.
I'm using the Dev-C++ program from Bloodshed to write the tutorial programs... just going through pointers at the moment, hoping it will all "gell" at some point.
I've also downloaded the book "Thinking in C++, 2nd Edition, Volume 1 Copyright (c)2000 by Bruce Eckel www.BruceEckel.com and have ready the first chapter... but that kinda fried my brain... so I started in on the C++ tutorial above, and will come back to the theory later - [once again hoping for the "gell" effect to take place]...
C++ Language Tutorial
Weird synchronicity of life... I have just started working through this tutorial to try and learn C++.
I'm using the Dev-C++ program from Bloodshed to write the tutorial programs... just going through pointers at the moment, hoping it will all "gell" at some point.
I've also downloaded the book "Thinking in C++, 2nd Edition, Volume 1 Copyright (c)2000 by Bruce Eckel www.BruceEckel.com and have ready the first chapter... but that kinda fried my brain... so I started in on the C++ tutorial above, and will come back to the theory later - [once again hoping for the "gell" effect to take place]...
I do not think there is a string data type in C, however there IS one in C++ (which is a far better language than C, but one you are best off learning C than moving to). Well, strictly speaking, the string data type in C++ is a basic class, but to all intents and purposes we might as well consider it a data type.
Personally I do not know any Pascal, and neither do I see any real reason to bother at this stage. The languages that I consider as useful/important now and in the future are: C, C++, C#, Visual Basic, Java, Qt, Mono (once it actually gets a little further), KBasic and others.
As for C string tutorials, you could try:
here
Or:
Here
Or you could just try asking me a little about strings if you want...
Personally I do not know any Pascal, and neither do I see any real reason to bother at this stage. The languages that I consider as useful/important now and in the future are: C, C++, C#, Visual Basic, Java, Qt, Mono (once it actually gets a little further), KBasic and others.
As for C string tutorials, you could try:
here
Or:
Here
Or you could just try asking me a little about strings if you want...
Woops! How did I manage to get it that wrong...oh well...
Dev C++ is the program I use for my C/C++ work, it is by far the best free alternative.
As for textbooks, I use C++: From Here to There, it is not free but is a really good textbook that gradually introduces the object-orientated features of C++, which make C++ more than just a better structured extension to C. However, as it is free I will definetely try that other textbook, thanks for the tip.
Dev C++ is the program I use for my C/C++ work, it is by far the best free alternative.
As for textbooks, I use C++: From Here to There, it is not free but is a really good textbook that gradually introduces the object-orientated features of C++, which make C++ more than just a better structured extension to C. However, as it is free I will definetely try that other textbook, thanks for the tip.
The tutorials are great, but I didn't found what I was looking for. Can someone write the val function for me?
Could you not import your pascal functions into C?
mm
mm
I've downloaded a few tutorial files which I reserved for close reading once I have enough time to give it justice. I still have to check Glennglenn's www.about.com
But I'm anxiously waiting for binarycode's tutorial on the basics of programming (what it is, and simple, baby steps to go about learning it).
There's a complete idiot waiting for this - ME. *LOL* Please note that even the TMOD - Boating - is a bit way over my head. And the rest of the tutorials i gathered may be easily understood and digested once I understand the basic of basics.
Then it will be an "Oh, happy day!" for me...my version of "Eureka!"
But I'm anxiously waiting for binarycode's tutorial on the basics of programming (what it is, and simple, baby steps to go about learning it).
There's a complete idiot waiting for this - ME. *LOL* Please note that even the TMOD - Boating - is a bit way over my head. And the rest of the tutorials i gathered may be easily understood and digested once I understand the basic of basics.
Then it will be an "Oh, happy day!" for me...my version of "Eureka!"
Meanwhile, when trying to learn how to script DinkC, you might as well check out The Rudiments of Scripting over here. I've found it easier to start with than Dink Goes Boating, which is an excellent "tutorial" to read after this one.
The way I learnt to script is... euhm... tut1.txt + dinkc.txt
The way I learnt to script is... euhm... tut1.txt + dinkc.txt
I learned DinkC in tut1 and Ruidiments of scripting.
I've learnt through a mixture of tutorials, experimenting with scripts and looking at the scripts of other dmods. There has been a little bit of extrapulation as well. In fact in the last week I've learnt several things about scripting that has improved the new and hopefully final version of Treasury that I am working on. I'm currently up to the third Beta version for it. I'm also starting on the second Beta of a new file set called Bestiary (monster scripts).
I have read through the about.com tutorials, but I didn't read 'em so good so I dunno if they work well for a noobie like me and you diawata I didn't read it so good, 'couse I have 2 books on C and C++ on my computer desk right now, and I am actually too lazy to read them too lol
I've got one book about C++, but it's 740 pages, so I feel a bit intimidated.
Go to your local library and borrow it mate
Actually my local library is useless for that sort of book. Besides I want to own a copy.
Why? I found one at my local library, but that was a C and a PHP book, and I have borrowed the C++ from my friends dad
Because borrowed things have to be returned unlike thing you own. Besides as I said, the local library is useless for programming tutorial books.
the local library is useless for programming tutorial books
I found a C++ book at a bookshop. It was about 70RON(my mother earns about 300 RON in a month). I put it back on the shelf.
I found a C++ book at a bookshop. It was about 70RON(my mother earns about 300 RON in a month). I put it back on the shelf.
For all of you who aren't from Romania:
70RON is about 22.56 Dollar or 19.14 Euro. according to this currency convertor.
The book I bought was something like 15 Euro (or 17,68 Dollar) I believe... Which is pretty cheap considering the average prices of books around here.
70RON is about 22.56 Dollar or 19.14 Euro. according to this currency convertor.
The book I bought was something like 15 Euro (or 17,68 Dollar) I believe... Which is pretty cheap considering the average prices of books around here.
You have to realize that a currencys value is not a pure representation of its buying power.
I like the gold coins that have chocolate inside.
Programming books are $100+ here in New Zealand, so are well out of my price range.
Thanks for all the advice, good people. I have downloaded what I think I need to start with basic DMOD making - my biggest problem is time, really.
Books are expensive here in the Philippines. Programming books, more so My father who was one of the first few in my country who studied computer programming (Cobol, I think) when he was young (he's in his 70s) is very much into it - I was about to ask him to send me some programming books from the US. I didn't know it was that expensive! *Sigh* I guess I'd better make do with the tutorials that I find here first.
FYI: I'm building a small, open library for kids and adults in my farm community - to encourage reading, on top of literacy programs (for tribal people) that responsible friends have started.It's not so much for the monetary value but more importantly, the efforts and thoughts poured into books - for me - that make most books sacred. This is in a way how I look at DMODs, and RPGs in general - a product of human intellect and of individuality/identity. I'm hoping I could muster enough brainpower to learn basic programming to pass on to our younger generation. I'm so happy I found this network where people are willing to help out.
Books are expensive here in the Philippines. Programming books, more so My father who was one of the first few in my country who studied computer programming (Cobol, I think) when he was young (he's in his 70s) is very much into it - I was about to ask him to send me some programming books from the US. I didn't know it was that expensive! *Sigh* I guess I'd better make do with the tutorials that I find here first.
FYI: I'm building a small, open library for kids and adults in my farm community - to encourage reading, on top of literacy programs (for tribal people) that responsible friends have started.It's not so much for the monetary value but more importantly, the efforts and thoughts poured into books - for me - that make most books sacred. This is in a way how I look at DMODs, and RPGs in general - a product of human intellect and of individuality/identity. I'm hoping I could muster enough brainpower to learn basic programming to pass on to our younger generation. I'm so happy I found this network where people are willing to help out.
Yeah, you're pretty right at that. I should know, I've been to eastern Europe quite a lot. (atleast what we call eastern Europe in Holland, technically it's central Europe)
I have only recently gotten over some major computer issues (well a few days ago now) and have had time to redownload resintall stuff now, and to catch up on other projects, so I can go back to working on this.
I have also delayed the release of this until I can get it into chm/html help file format. If anyone can point me towards a decent tool I can use for this, please do so. The first installment should go further into C than I oringally planned, alot further than introducting Data Types.
I have also delayed the release of this until I can get it into chm/html help file format. If anyone can point me towards a decent tool I can use for this, please do so. The first installment should go further into C than I oringally planned, alot further than introducting Data Types.
hey diwata, have you ever tried using linux? Your philosophies sound a lot like the ones on this page, www.ubuntulinux.org. Linux is free, so i think it's perfect for projects like small community libraries. They'll even send you some cds for free, in case you can't download/burn. I always like that dev programs are easily accessed.
Dev C++ is the program I use for my C/C++ work, it is by far the best free alternative.
Have you tried Code::Blocks?
IMO, Dev-C++ is way too slow (especially with auto-completion enabled (which I don't use btw )).
Have you tried Code::Blocks?
IMO, Dev-C++ is way too slow (especially with auto-completion enabled (which I don't use btw )).
OK, after being distracted with some other stuff, I have finally released the first part of this into the public domain. Part One is all about C Programming Fundamentals. While it does not teach any actual code, it introduces key programming concepts a C programmer should know, and includes a brief bit on why one would want to bother learning programming in the first place.
Next week I should release Part Two - Data and Function calling, where some coding is finally done, as well as a brief section on documentation (comments).
it is broken up into five .rtf documents, all zipped up in one folder, to a nice 18 odd k's, small enough for the worst connection.
If you want to go take a look, go to my programming forum (which is still very new, so excuse the lack of posts yet, I have high plans, and if YOU post stuff, others might follow your lead) which uses the excellent Invision Board System.
I am looking for mods for the forum, so if you are interested, let me know.
Anyway, enjoy the tutorials and if you have any questions, comments, email me.
The link to the forums is:
Programming Forum
The link straight to the thread with the tutorials is:
C Tutorial zip file
Next week I should release Part Two - Data and Function calling, where some coding is finally done, as well as a brief section on documentation (comments).
it is broken up into five .rtf documents, all zipped up in one folder, to a nice 18 odd k's, small enough for the worst connection.
If you want to go take a look, go to my programming forum (which is still very new, so excuse the lack of posts yet, I have high plans, and if YOU post stuff, others might follow your lead) which uses the excellent Invision Board System.
I am looking for mods for the forum, so if you are interested, let me know.
Anyway, enjoy the tutorials and if you have any questions, comments, email me.
The link to the forums is:
Programming Forum
The link straight to the thread with the tutorials is:
C Tutorial zip file
February 3rd 2006, 12:51 AM
toa
void val(string s, int x, int err);
If the chars contained by s were digits, then x would become the number value contained in s. If not, the err varaible would indicate the position of the first non-digit char.
Is anything similar in C? Can you indicate me a good tutorials about strings, in C?
strtol() or strtoul()
They're in either stdlib.h or string.h (I forget which).
If you want error checking:
errno = 0;
myval = strtol(s,NULL,0);
if (errno) { /*error-handling goes here*/; }
As for tutorials on strings in C:
Rule 1: Don't use string.h.
Rule 2: Don't use char* as a string type.
Rule 3: Find a good dynamic string library.
Rule 3 gives you your tutorial, since any good string lib will have documentation.
If the chars contained by s were digits, then x would become the number value contained in s. If not, the err varaible would indicate the position of the first non-digit char.
Is anything similar in C? Can you indicate me a good tutorials about strings, in C?
strtol() or strtoul()
They're in either stdlib.h or string.h (I forget which).
If you want error checking:
errno = 0;
myval = strtol(s,NULL,0);
if (errno) { /*error-handling goes here*/; }
As for tutorials on strings in C:
Rule 1: Don't use string.h.
Rule 2: Don't use char* as a string type.
Rule 3: Find a good dynamic string library.
Rule 3 gives you your tutorial, since any good string lib will have documentation.
Oh, I found that function a few weeks ago. They are meore than one. The most close to val is sscanf, which scans a number from a string(similar to fscanf, but the file variable is replaced by a string variable).
The function from stdlib.h were atoi, atol(string to number), and itoa, ltoa(number to string).
Now I know C pretty well. I can do in C all the things I could do in Pascal, even more. Now I'm prepairing for a programming contest. The thing I have to learn are now, graphs, graphs, even more graphs, and of course, dynamical programing(that kind of programming that gives the best solution, in low time).
The function from stdlib.h were atoi, atol(string to number), and itoa, ltoa(number to string).
Now I know C pretty well. I can do in C all the things I could do in Pascal, even more. Now I'm prepairing for a programming contest. The thing I have to learn are now, graphs, graphs, even more graphs, and of course, dynamical programing(that kind of programming that gives the best solution, in low time).
February 4th 2006, 03:49 AM
toa
First: sscanf has dodgy semantics around whitespace. Be careful.
Second: Dynamic programming? After just a few weeks in C? How long have you been working in Pascal and what kind of projects did you work on?
Third: What contest? I might like to try my hand at it.
Second: Dynamic programming? After just a few weeks in C? How long have you been working in Pascal and what kind of projects did you work on?
Third: What contest? I might like to try my hand at it.
I studied Pascal from 2002. I don't think you could compete on this contest because you're not from Romania, and this is the a Romanian contest. You don't have to do a project or something. You have three hours to make two programs. Usually, you read some datos from a file and you should create another file with some other datos(e.g.: you read a maze from a file, and you have to print the solution). There are some automatic evaluators that runs your programs and checks your solution. And the most important thing is that your programs have a time limit(usually 1second). The evaluators give several tests. The first ones are easy, so your programs finds the solution in less than 1sec, nomatter what method you use. But for most of the tests, backtracking, or any other exponential alghoritms are useless.
Wish me luck.
Wish me luck.
Best of luck... or as my mum has a tendency to say (when she decides to call)...'Go to your destiny'
Today I had the first faze of the computer olympiad(the zonal one). From what my teacher knows(and she don't know anything sure) I'm the third, and I took 110/200 points. If you're interested, I can translate the two problems and post them here.
The whole thing would be meaningless to me (if you posted them)... but I'm writing to say 'Congrats'... well done.
Thanks. Here's the first one(I was too lazy to translate the second one too, but I'll do it). It's quite easy, but the second one was hard.
Problem 1:
In a group of n persons, there are pairs of persons considered friends. Considering my friend's
friend is my friend, identify all the groups made by exactly k persons that are friends(directly or
indirectly).
Input datos:
-k is read from the keyboard
-there is a file called graph.txt that contains on the first line n(the number of persons), and on
the next lines are pairs of numbers which represents the friendship relations.
Output datos:
-the results should be written in the file group.txt
-on each line, there should be written a group of persons
Examples:
k=3
graph.txt
9
1 2
4 5
2 3
7 8
7 9
group.txt (this way it should look)
1 2 3
7 8 9
k=2
graph.txt
3
1 2
2 3
group.txt(it shouldn't contain anything)
Problem 1:
In a group of n persons, there are pairs of persons considered friends. Considering my friend's
friend is my friend, identify all the groups made by exactly k persons that are friends(directly or
indirectly).
Input datos:
-k is read from the keyboard
-there is a file called graph.txt that contains on the first line n(the number of persons), and on
the next lines are pairs of numbers which represents the friendship relations.
Output datos:
-the results should be written in the file group.txt
-on each line, there should be written a group of persons
Examples:
k=3
graph.txt
9
1 2
4 5
2 3
7 8
7 9
group.txt (this way it should look)
1 2 3
7 8 9
k=2
graph.txt
3
1 2
2 3
group.txt(it shouldn't contain anything)