Iscn Posted September 13, 2012 Author Share Posted September 13, 2012 **Note!*** Before you start, get a C++ program editor ex:Bloodshed Dev-C++. I highly recommend it! it is free. Just google it.* After you have it follow the following steps. This is for Dev C++(i highly recomend it! Visual Studio is a bit tricky to set up)1. After installation open it up.2. Click on file ->> new project.3. Name it what ever you want & select empty project.4. Click okay and open it up.5. Now right click on project and creat new file.6. Rename the file but make sure it end with cpp. Ex:``` main.cpp ```**Media:**>! ![](http://i.imgur.com/8FgEG.png) * Right now your screen is pretty blank right now. Well lets change that.* Remember to start the entire code with: ``` #include using namespace std; int main() { ```This code does nothing so far. Our objective is to display a sentence saying hello world.Look In Spoiler For Demonstration!**Media:**>! ![](http://i.imgur.com/vNuyZ.png) Okay now to display something in c++, we use cout. (C-OUT).```cout << "text here";```Using```cout```&```<<```&```"text here";```will show a message saying```text here```When you use the```cout <<```letters, it means or shows that you want to display something.For example:```int a=3;cout << a;will display 3 because you used cout << & the variable a.Please don't be confused to think that you need a variable to use cout.you can use cout << with anything.To display a text or i would say anything when you run your program, you can use either:cout << & variable OR cout << "text here";The "text here" is to show you how to make it display a text or word etc.```Also know that for some statements or lines of code to work they must always end with the symbol:``` ;```If not you will get an error.Now lets try to setup a hello world project with what you just learned.If you need help you can copy and paste the code provide below.(OPEN SPOILER)It is not necessary that you use my procedure you can use different alternatives. But for now i recomend you use my way so that you can edit it later to test and try out.Code Snippet:>! ```>! #include using namespace std;>! int main()>! {>! cout<<"your text here";>! cin.get();>! return 0;>! } ```>! I added```cin.get(); ```which will keep the window open untill you click anykey on your keyboard. This way you can see how the texts look like. If you got it nice job. Congrats!. If not try again & post problems and comments belowYou can now move on to next bit.**Variables & Variable Identifiers :*** First lets talk about variables.Lets say you have to take care of your monthly expenses. Now you can have rent expense, grocery, misc expense & others. And you have to keep track of all of them and how much they are every month.* Example:```Rent Expense = 100;Grocery = 45Misc Expense = 200```* That is what a variable is pretty much, that bunch of numbers you have to keep track of.* But consider that your computer can store millions of numbers like these at the same time and conduct sophisticated mathematical operations with them.* Each variable needs an identifier that distinguishes it from the others.* For example, in the previous code the variable identifiers were rent expense, grocery and Misc Expense.* In real life we can call them that if we wanted but in programming world there are some set backs.* We can call the variables any names we want to invent, as long as they are valid identifiers.A variable identifier is used to let me say "brand' a variable. In C++ an identifier can be one or more letters, digits or underscore characters (_). You can't have a space or punctuation marks or symbols.Ex:```Proper Identifiers:int newName;int new_name;int new123;Bad Identifiers:int new.name;int 123wower;int 123Meow;[color]int new; ( it is a reserved word.) [/color][color]int n ew; no spaces allowed.[/color][color]They always have to begin with a letter not numbers!You can begin with underscores too, but in some cases these may be reserved for compiler specific keywords or external identifiers.Another rule that you have to consider when inventing your own identifiers is that they cannot match any keyword of the C++ language nor your compiler's specific ones, which are [i]reserved keywords[/i].Reserved Keywords:[code]asm, auto, bool, break, case, catch, char, class, const, const_cast, continue, default, delete, do, double, dynamic_cast, else, enum, explicit, export, extern, false, float, for, friend, goto, if, inline, int, long, mutable, namespace, new, operator, private, protected, public, register, reinterpret_cast, return, short, signed, sizeof, static, static_cast, struct, switch, template, this, throw, true, try, typedef, typeid, typename, union, unsigned, using, virtual, void, volatile, wchar_t, while[/code]There are others you can't use certain times.[code]and, and_eq, bitand, bitor, compl, not, not_eq, or, or_eq, xor, xor_eq[/code]Also know that your compiler might also have it's own reserved keywords.[b]Very important:[/b] The C++ language is a [i]"[/i]case sensitive[i]"[/i] language. That means that an identifier written in capital letters is not equivalent to another one with the same name but written in small letters.Example:[code]RESULT [/code]variable is not the same as the[code]result[/code]variable or the[code]Result[/code]variable.These are three different variable identifiers.And that is pretty much most of what you need to know for C++ Variables & Variable Identifiers.[/color][color]Thank you for your time. By now you should have a good understanding of variables and how to write them right.[/color][color]Post problems & comments below![/color][color]Thank you for your Time.[/color]``` Link to comment Share on other sites More sharing options...
Iscn Posted September 13, 2012 Author Share Posted September 13, 2012 Reserved Link to comment Share on other sites More sharing options...
Guest Posted September 13, 2012 Share Posted September 13, 2012 "A computer can make decisions based on data given to it. A calculator is a computer because to makes decisions based on the input you give it."What you've written there is essentially the same thing. Data doesn't magically appear, it has to be manually inputted at some point. Link to comment Share on other sites More sharing options...
Iscn Posted September 13, 2012 Author Share Posted September 13, 2012 > "A computer can make decisions based on data given to it. A calculator is a computer because to makes decisions based on the input you give it."> > What you've written there is essentially the same thing. Data doesn't magically appear, it has to be manually inputted at some point.Yeah i wanted to give an example, like something they can relate to. Link to comment Share on other sites More sharing options...
AeroEBrown Posted September 13, 2012 Share Posted September 13, 2012 This is a terrible post.I am moving this to Off-Topic until you modify it to not only format it uniformally, but also edit the content to be factual information instead of a garbled mess.Thanks,Aeroplane Link to comment Share on other sites More sharing options...
Iscn Posted September 13, 2012 Author Share Posted September 13, 2012 > This is a terrible post.> > I am moving this to Off-Topic until you modify it to not only format it uniformally, but also edit the content to be factual information instead of a garbled mess.> > Thanks,> > Magical AeroplaneRe wrote the thread. Is it good now or just garbled mess and un factual information. Link to comment Share on other sites More sharing options...
SawQuart Posted September 13, 2012 Share Posted September 13, 2012 > Re wrote the thread. Is it good now or just garbled mess and un factual information.It's still very confusing. Are you experienced or are you new to C++? Link to comment Share on other sites More sharing options...
Marsh Posted September 13, 2012 Share Posted September 13, 2012 You seem really mixed up in your explanations. You are pointing out some basic stuff then confusing them with stuff they really dont need to know.Also this isnt really a start to programming at all. I suggest you explain some basic stuff like you (sort of) did and then go onto the classic hello world. Also this may just be me but i think people should learn c first. Or at least c style.Thanks for submitting the tut, though like Aero said it really is kind of a mess. Do you know c++ or are you learning yourself?Should also work on your formatting, unless code tags are just messing that up.[Edit]As you are editing it it is definitely improving. Link to comment Share on other sites More sharing options...
Iscn Posted September 13, 2012 Author Share Posted September 13, 2012 > It's still very confusing. Are you experienced or are you new to C++?I am new, but the language is easy to learn and i put my studies into the thread. Link to comment Share on other sites More sharing options...
Iscn Posted September 13, 2012 Author Share Posted September 13, 2012 > You seem really mixed up in your explanations. You are pointing out some basic stuff then confusing them with stuff they really dont need to know.> > Also this isnt really a start to programming at all. I suggest you explain some basic stuff like you (sort of) did and then go onto the classic hello world. Also this may just be me but i think people should learn c first. Or at least c style.> > Thanks for submitting the tut, though like Magical Aeroplane said it really is kind of a mess. Do you know c++ or are you learning yourself?> > [Edit]> > As you are editing it it is definitely improving.So should i make a seprate part just for beginners?I can make it into spoilers some parts. So beginners can learn the basics, & i guess advanced beginners can skip some parts. Link to comment Share on other sites More sharing options...
Iscn Posted September 14, 2012 Author Share Posted September 14, 2012 Edited the topic. Please Edit your comments if you must. Link to comment Share on other sites More sharing options...
Likestodraw Posted September 14, 2012 Share Posted September 14, 2012 Shouldn't this be moved to Programming? Link to comment Share on other sites More sharing options...
SawQuart Posted September 14, 2012 Share Posted September 14, 2012 > Shouldn't this be moved to Programming?Read the thread. Link to comment Share on other sites More sharing options...
Iscn Posted September 14, 2012 Author Share Posted September 14, 2012 > Shouldn't this be moved to Programming?Magical Aeroplane asked me to rewrite it and fix errors and mistakes.Give him some time he will move it.He moved it here in the first place. Link to comment Share on other sites More sharing options...
SawQuart Posted September 15, 2012 Share Posted September 15, 2012 > Magical Magical Aeroplane asked me to rewrite it and fix errors and mistakes.> > Give him some time he will move it.> > He moved it here in the first place.He won't move it back until you actually fix it >_>At least rename this "Introduction to C++ Basics" and not "C++ Hello World". It's a bit of an overload of information for someone looking to just output "hello world". Link to comment Share on other sites More sharing options...
Iscn Posted September 15, 2012 Author Share Posted September 15, 2012 > He won't move it back until you actually fix it >_>> > At least rename this "Introduction to C++ Basics" and not "C++ Hello World". It's a bit of an overload of information for someone looking to just output "hello world".Yeah lol i was thinking of changing the title but i think some one already beat me to it. Link to comment Share on other sites More sharing options...
blkcrow Posted September 15, 2012 Share Posted September 15, 2012 Dev c++? why would you even suggest that its been droped from its developers a long time ago Link to comment Share on other sites More sharing options...
Iscn Posted September 15, 2012 Author Share Posted September 15, 2012 > Dev c++? why would you even suggest that its been droped from its developers a long time agoBecause it works.And is still used by developers.There is no C++ compiler not used.I only recommended it because the setup is easy.You can try eclipse if you want same thing. A compiler is a compiler. Link to comment Share on other sites More sharing options...
blkcrow Posted September 15, 2012 Share Posted September 15, 2012 > Because it works.> > And is still used by developers.> > There is no C++ compiler not used.> > I only recommended it because the setup is easy.> > You can try eclipse if you want same thing. A compiler is a compiler.No thats not what i meant. Dec c++ has stoped being updated since 2005\. most c++ learning sites dont suggest using it simple simple because it hasnt got any support anymore. Also setting up an IDE isnt that hard there are step by step tutorials in every site Link to comment Share on other sites More sharing options...
Mal Posted September 15, 2012 Share Posted September 15, 2012 Just going to go ahead and leave this here: [http://www.microsoft.com/visualstudio/eng/products/visual-studio-2010-express](http://www.microsoft.com/visualstudio/eng/products/visual-studio-2010-express) Link to comment Share on other sites More sharing options...
SawQuart Posted September 15, 2012 Share Posted September 15, 2012 > A compiler is a compiler._right…_ Link to comment Share on other sites More sharing options...
Iscn Posted September 15, 2012 Author Share Posted September 15, 2012 > No thats not what i meant. Dec c++ has stoped being updated since 2005\. most c++ learning sites dont suggest using it simple simple because it hasnt got any support anymore. Also setting up an IDE isnt that hard there are step by step tutorials in every siteWell it still works fine.But it in the end it doesn't matter what compiler you use. As long as you have the right code it will work.I didn't look that well into Dec ++ , i didn't see it was not supported anymore.But i have the new beta version… if it is not supported why do they keep upgrading it. Link to comment Share on other sites More sharing options...
Keebler Elf Posted September 15, 2012 Share Posted September 15, 2012 Code Blocks is free and it is still updated. I first learned C++ using Dev c++ howevr the switch over to codeblocks was one of the best things I could have done. Link to comment Share on other sites More sharing options...
Iscn Posted September 16, 2012 Author Share Posted September 16, 2012 > Code Blocks is free and it is still updated. I first learned C++ using Dev c++ howevr the switch over to codeblocks was one of the best things I could have done.Yeah i started to use it now.Pretty nice.I only stick to Dev C++ because am still in C++ course in highschool and that is the compiler we are currently using. Link to comment Share on other sites More sharing options...
Godlord Posted September 16, 2012 Share Posted September 16, 2012 Dev-Cpp is an IDE, not a compiler. The compiler that is being shipped with Dev-Cpp by default is MinGW, which is a port of GCC for Microsoft Windows.Yours faithfullyS.J.R. van Schaik. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now