|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Long story short, i was watching a G4 show that showed the jobs of video game programmers and it looked really neat to me, especially because i have always been interested in video game programming and video games in general. i figured this would be a great career for me. keep in mind that i am only 13 years old and a total newbie to coding. i understand that this requires alot of patience, time and investment. i figure learning the basics will give me a headstart when i get into high school and college computer and technology classes. (ok, more like long story long
)anyway, here are the basics of C coding that i know so far after about an hour or so of reading through beginners guides. main() will begin a program execution ; (semi colon) basically ends the command int - whole numbers without decimal points float - real #s with decimal points char - keyboard characters; letters data-type identifier; form for delcaring a variable #= preprocess statement (no clue what it means) printf() displays formatted data on screen i know that i am far from knowing all the basics, that's why i am wondering if any of you guys could update me with some of the main things i should know, correct any wrong info i put here. also, putting some of these terms into simpler terms would help alot. please keep in mind that i'm only 13. i DO have a more expanded vocabulary then the average teenager, but i DON'T know a whole lot of words involving C programming. thanks for any feedback. ![]() |
| Sponsored Links |
|
|
|
|||||
|
Welcome to CodeCall, Justin!
From what you told us, we can basically short it down to three main things you know about: functions, datatypes and preprocessors. You know some of the basic types, such as char, int, float, and so on. Those are also something, that in C, C++ and many other languages are called keywords. Keywords are standardized, built-in datatypes, and that means you can't make a variable, with f.ex. the name "char." printf() is the standard way to output, yeah... some output. There's other functions for outputting too, but of different kinds. There's output functions for errors, other streams, and so on. Your description of the main() function is both true, but also not. It's right that's where the program execution starts, but actually you could call it whatever you want, and give another entry point to the linker, though that isn't standard-C. I just said it, so you have it in the back of your head. Preprocessors are some somewhat strange fellows. The preprocessor directives never comes into the actual machinecode, f.ex. an exectuable file. It's removed during the compiler process, where the compiler substitutes with other functionality. F.ex. a macro, it works a little similar to LISP. If you f.ex. have this C-macro: Code:
#define MakeString(str) #str
// ...
printf("%s\n", MakeString(Hello!));
Code:
printf("%s\n", "Hello!");
Conditional structure This is one of the most important parts to get a program to work, or at least have some functionality, than just printing a message to the user. What I'm talking about is if and else. There's not much to talk about in this little section, so I'll provide you some links to move on. This is not the best one... ... this one is better. Iteration structures (also knows as loops) This is another great thing, that you HAVE to learn. This is, like the conditional structures, in the category; most basic C-programming. There's more types of iteration structures, than conditional structures. The existing ones are: for, while, do...while, and I'll also say labels, goto, break and continue. This one is not C-specific. This one is, though. Selective structures I'm only familiar with one, and it's the switch-statement. switch is a great alternative to if-statements, sometimes. If you've many options to choose from, the switch-statement is the best one to choose. This is C++, but you can use it for C too. This one is neither, but you can still use it. But this one is aimed at C. Functions There's a lot more in functions, that I've told you before, and from what I think you know. You need to learn about parameters, arguments, returntypes, etc. So there's a lot to learn about. There's also something called function pointers, but I'll return to that in the pointer-section. Another feature that's wide-used in computing, is recursion. This is for C. This is for C++. And this is for C++ too. Pointers Pointers is a really great feature in C, but it's also hard for beginners, both to use, and to understand. If I've to say it short, then pointers are like variables, but point to other variables memory addresses. There's also pointer-to-pointers, functions pointers and much more. This one is for C. And this is mostly for C. And finally a lot of information on function pointers. Array Arrays are somewhat like pointers, and can be used in somewhat the same way, but there's still a difference. You'll learn more about this, when you're reading more about it. Arrays in general, and some mathematics. Arrays in C++. And arrays in C. Input/Output (also know as I/O) You need to learn how to communicate with the user, or the computer itself. There's many ways, and many kinds of I/O, and the printf() is just a small part of everything. This is something you HAVE to learn about, it's a very important parts of programs, though you can make programs without a user interface at all. I'll only provide links for file i/o. I/O in general. This is in C++, and can be hard to use in C. But this is for C only. Typecasting (also know as type conversion) You've to learn about typecasting, because C is a relative low-level language, and you often have to convert from one type to another. In other languages such as LISP, Python, etc. it's very easy, because they're so high-level, but C isn't. This is mostly in general, but with a bit C. And this is for C. Structures Structures make it possible for you, to make your own datatypes. The keyword used for this is struct. In C++ this keyword isn't used as much as in C, because in C++ we've class. But this is the only option for a C-programmer, so it's a must-learn. This is mainly for C++, but can be used in C too. This is aimed at C. That's the most basic C-stuff you've to learn, but it's a big world, and there's a lot more to learn, than just this. You need to go down to your local bookstore, or library and buy or borrow (respectively), and read about the C-language in details. There's also a lot of information at the internet, and a huge user database, which you can find in forums, usenet, irc, or anywhere else. Good luck with everything, and if you someday get some problems, then return to CodeCall, and just ask us, and we'll help as much as we're able to.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
|
|||||
|
Polymorphism and templates are easy to understand once you realise that they are really just the same as functions.
You want to use a function when you are doing the same process with different data. For example, suppose you know how to calculate the square root of two. And you know how to calculate the square root of three, and you know how to calculate the square root of four, ... You are doing the same process (calculating square roots) on different data (2, 3, 4, ...) So you make a function that looks like this: Code:
double sqrt(int n); Now, when making complex data types, we find the same situation on a different level. In one program, you might want to store integers in a linked list. So (in C) you would make a data type called linked_list_integer. In another program, you might want to store strings in a linked list, so you would make a data type called linked_list_string. See the pattern here is the same as before. We know what a linked list is, and it seems pointless to have to make a different linked list each time we want to store a different data type in the list. So what we use (in C++) is a template. A template is like a function, but instead of having a parameter that is an integer or a float or a string, the parameter is a data type. So our template for a linked list would look like this: Code:
template <class t>
class linked_list
{
... code that implements a linked list, using the parameter t as the data type stored in the list ...
}
Angled brackets are used for template parameters to make them look different to function parameters, to avoid confusion. So the linked_list class is an example of a template because it has a template parameter t. We say that the linked list class is polymorphic in the type of data that it can hold. This website provides a very good introduction to templates, and some code examples along the lines of what I have been describing. Good luck with your coding, kisna and justin1993.
__________________
My fun, friendly online games website: Cygnet Games My Squidoo page on Cygnet Games. |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pseudocode Tutorial: The Basics | TcM | Tutorials | 5 | 06-06-2008 01:44 PM |
| C++ Basics | Deathcry | C and C++ | 5 | 06-13-2007 04:04 PM |
| The Basics Of VB Express | pcdctr | Visual Basic Programming | 5 | 05-28-2007 07:01 AM |
| Project: vBulletin Alert System (vbAS) | Crane | Community Projects | 18 | 12-13-2006 10:54 AM |
| Basics Of PHP | sn17 | PHP Forum | 11 | 09-14-2006 08:26 PM |
| Xav | ........ | 1455.48 |
| MeTh0Dz|Reb0rn | ........ | 1089.45 |
| WingedPanther | ........ | 977.76 |
| marwex89 | ........ | 962.9 |
| John | ........ | 914.37 |
| morefood2001 | ........ | 911.18 |
| Brandon W | ........ | 823.79 |
| chili5 | ........ | 312.39 |
| Steve.L | ........ | 276.28 |
| dcs | ........ | 253.49 |
Goal: 100,000 Posts
Complete: 84%