First  Prev  1  2  3  4  5  Next  Last
Kondo's C++ class
Sensei
3193 cr points
Send Message: Send PM GB Post
25 / M
Offline
Posted 8/5/08 , edited 8/5/08
Lesson 1
This only works with the c++ compiler go download is here http://www.microsoft.com/express/vc/
so here it is your first program, i will go over the meaning of it in lesson 2

1. go to file and under new press new project
2. Type "Hello World" as the name
3. click finish
4. Your new window should have some text written on it, delete ALL of it
5. type the following things verbatim, DO NOT copy and paste

#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
cout << "Hello World!";
char a;
cin >> a;
return 0;
}

once you have done this go to project properties --> configuration type and then make sure it says application (.exe)
Then go to debug and click on debug or debug solution (can't remember which one)
a window should pop up and say "Hello World!"
Sensei
37303 cr points
Send Message: Send PM GB Post
27 / F / Narnia, Closet
Offline
Posted 8/5/08 , edited 8/5/08
.......I finally got it.
It took me awhile to figure where configuration type was at, but I got it.
Sensei
3193 cr points
Send Message: Send PM GB Post
25 / M
Offline
Posted 8/5/08

sanchez2007x1 wrote:

.......I finally got it.
It took me awhile to figure where configuration type was at, but I got it.


Congratulations on your first program! I recommend you fiddle with it while everyone else is catching up because fiddling is the best way to get familiar with C++
Sensei
10136 cr points
Send Message: Send PM GB Post
24 / M / The Universe is a...
Offline
Posted 8/5/08
Crap!! I did it!! hehehe!!
Sensei
3193 cr points
Send Message: Send PM GB Post
25 / M
Offline
Posted 8/6/08
Lesson 2.
I am now going to explain what this programming code means

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
cout << "Hello World!";
char a;
cin >> a;

return 0;
}

The first two lines of code are "pre-processor commands" remember that (they are labeled with a #. That means they are commands completed before the main "function" (remember that too). The "include" means that we are going to include the header file we specified, a header file is like a library of commands that we can use any command from.
So if there was a header file named "math" and we wanted to perform addition, we would use that command from the header file (In C++ addition is much easier than this don't worry).
The next line of code is using namespace std; this is a command I will get into later but it works something like this

If I didn't use this command my code would look like this
#include "stdafx.h"
#include <iostream>

int main()
{
std::cout << "Hello World!";
char a;
std::cin >> a;
return 0;
}

The commands "cout" and "cin" and commands found in the "iostream" header and use the "std" to signify that it is from that header file.

If you noticed at the end of the "using namespace std" line there is a semicolon ( ; ) at the end, this is important in C++, because most commands have to end with a semicolon to let the computer know your command is done, so the computer can go onto the next command. The next line which is purple is the name of the main "function" we will get more into that later, but just remember that your program will not work if it does not have any functions in it. The brackets ( { }) are used to show where the beginning and end of the "block of code" is, the block of code in this case, is all the commands i put inside of the main function. Next is the cout << command. This command prints out whatever you put on the right onto the screen. If you want to write text directly you need a pair of quotation marks, when we get into variable you will not need them though. The next "line of code" (remember this too it means whatever is on the next line)
is char a;. This is a variable, I will explain how this works in the next lesson or maybe the third lesson. The next line of code is cin >> a;, I will also explain this in another lesson. The last line of code before the "ending brace"( the } at the end of the block of code) is return 0;, this is command that returns the number next to it (don't worry I will explain this when we get into functions).

In C++ the spacing is very lenient, and you could skip ten lines between each statement (some exceptions), but make sure you only write one command per line, it will make it harder to read, harder to understand, and much harder to fix. So...

#include "stdafx.h"






#include <iostream>






using namespace std;

int main()
{



cout << "Hello World!";



char a;


cin >> a;


return 0;


}
This will not produce any errors or warnings (errors are fatal, warnings are not, whereas a fatal error will not allow your program to work a warning will allow your program to work but it may or may not work correctly)


That's it for this lesson try out what you have learned while I prepare the next lesson.
Vice President
69515 cr points
Send Message: Send PM GB Post
34 / M / ...
Offline
Posted 8/6/08
Sweeet! I had the time and did it, finally! ahhh Kondo-san wa jouzu da ne... hontou..
Sensei
3193 cr points
Send Message: Send PM GB Post
25 / M
Offline
Posted 8/6/08

Fruitspunchsamurai wrote:

Sweeet! I had the time and did it, finally! ahhh Kondo-san wa jouzu da ne... hontou..


Don't you feel accomplished after making your first computer program? I did back when I was 8. But that was with Visual Basic so that shouldn't count, C++ is much more useful than visual basic (most of the time)
Sensei
10136 cr points
Send Message: Send PM GB Post
24 / M / The Universe is a...
Offline
Posted 8/6/08

fruitschinposamurai wrote:


Fruitspunchsamurai wrote:

Sweeet! I had the time and did it, finally! ahhh Kondo-san wa jouzu da ne... hontou..


Don't you feel accomplished after making your first computer program? I did back when I was 8. But that was with Visual Basic so that shouldn't count, C++ is much more useful than visual basic (most of the time)


Wowo, you did that kind of work when you're 8, I was still an idiot at that time HAHAH!!
Sensei
3193 cr points
Send Message: Send PM GB Post
25 / M
Offline
Posted 8/6/08

Nyctophyll wrote:


fruitschinposamurai wrote:


Fruitspunchsamurai wrote:

Sweeet! I had the time and did it, finally! ahhh Kondo-san wa jouzu da ne... hontou..


Don't you feel accomplished after making your first computer program? I did back when I was 8. But that was with Visual Basic so that shouldn't count, C++ is much more useful than visual basic (most of the time)


Wowo, you did that kind of work when you're 8, I was still an idiot at that time HAHAH!!


You are misunderstanding its not like i understood most of the things i did. And majority of what i wrote when I was younger was done by my father. The only reason I mentioned this was to put emphasis on how easy this program is.
Sensei
10136 cr points
Send Message: Send PM GB Post
24 / M / The Universe is a...
Offline
Posted 8/6/08 , edited 8/6/08

fruitschinposamurai wrote:


Nyctophyll wrote:


fruitschinposamurai wrote:


Fruitspunchsamurai wrote:

Sweeet! I had the time and did it, finally! ahhh Kondo-san wa jouzu da ne... hontou..


Don't you feel accomplished after making your first computer program? I did back when I was 8. But that was with Visual Basic so that shouldn't count, C++ is much more useful than visual basic (most of the time)


Wowo, you did that kind of work when you're 8, I was still an idiot at that time HAHAH!!


You are misunderstanding its not like i understood most of the things i did. And majority of what i wrote when I was younger was done by my father. The only reason I mentioned this was to put emphasis on how easy this program is.


But still, I cant understand what you are saying if Im still 8, too immature and stupid after all. I was interested in computers when I was 10 or 11. I see that it is really easy though, btw, do the hackers use this to hack PSP into making CFW and such? (just wondering)
Sensei
3193 cr points
Send Message: Send PM GB Post
25 / M
Offline
Posted 8/6/08 , edited 8/6/08

Nyctophyll wrote:


fruitschinposamurai wrote:


Nyctophyll wrote:


fruitschinposamurai wrote:


Fruitspunchsamurai wrote:

Sweeet! I had the time and did it, finally! ahhh Kondo-san wa jouzu da ne... hontou..


Don't you feel accomplished after making your first computer program? I did back when I was 8. But that was with Visual Basic so that shouldn't count, C++ is much more useful than visual basic (most of the time)


Wowo, you did that kind of work when you're 8, I was still an idiot at that time HAHAH!!


You are misunderstanding its not like i understood most of the things i did. And majority of what i wrote when I was younger was done by my father. The only reason I mentioned this was to put emphasis on how easy this program is.


But still, I cant understand what you are saying if Im still 8, too immature and stupid after all. I was interested in computers when I was 10 or 11. I see that it is really easy though, btw, do the hackers use this to hack PSP into making CFW and such? (just wondering)


I meant that this program is so easy an 8 year old can make it, literally. And hackers sometimes use C++ in making custom firmware, but more of it is done in C, because C++ is used for different things than C.
Sensei
10136 cr points
Send Message: Send PM GB Post
24 / M / The Universe is a...
Offline
Posted 8/6/08

fruitschinposamurai wrote:


Nyctophyll wrote:


fruitschinposamurai wrote:


Nyctophyll wrote:


fruitschinposamurai wrote:


Fruitspunchsamurai wrote:

Sweeet! I had the time and did it, finally! ahhh Kondo-san wa jouzu da ne... hontou..


Don't you feel accomplished after making your first computer program? I did back when I was 8. But that was with Visual Basic so that shouldn't count, C++ is much more useful than visual basic (most of the time)


Wowo, you did that kind of work when you're 8, I was still an idiot at that time HAHAH!!


You are misunderstanding its not like i understood most of the things i did. And majority of what i wrote when I was younger was done by my father. The only reason I mentioned this was to put emphasis on how easy this program is.


But still, I cant understand what you are saying if Im still 8, too immature and stupid after all. I was interested in computers when I was 10 or 11. I see that it is really easy though, btw, do the hackers use this to hack PSP into making CFW and such? (just wondering)


I meant that this program is so easy an 8 year old can make it, literally. And hackers sometimes use C++ in making custom firmware, but more of it is done in C, because C++ is used for different things than C.


ohh..........got it, i think its more of "its so easy a caveman, can do it" lol
Sensei
3193 cr points
Send Message: Send PM GB Post
25 / M
Offline
Posted 8/6/08 , edited 8/6/08
I have made some questions to make sure you read my lessons carefully
1. Find and fix all the errors in this program. There are 7 mistakes if you fix it one way and 8 if you fix it another way

include "stdafx.h"


int main()
{
cout << "Hello World!"
char a
cin >> a
return 0



2.What is a header file?

3. Why do the keywords cout and cin need header files?

4. What is the keyword cout used for?

BONUS
5. Why do you think quotation marks are needed when using the cout keyword?
(hint words are not the only thing cout and output onto a screen)
Sensei
10136 cr points
Send Message: Send PM GB Post
24 / M / The Universe is a...
Offline
Posted 8/6/08 , edited 8/6/08

fruitschinposamurai wrote:



1.
#include "stdafx.h" <--------
#include <iostream> <--------- was this right?
using namespace std; <------

int main()
{
cout << "Hello World!";
char a;
cin >> a;
return 0;
}

2. The header file will become the message inside the .exe file?
3. The keywords are needed cuz those are the commands that will make the header show up in the window/screen.
4. Same as above, no valuable infos referring to cin >> a; cuz you will teach it to us on the next lesson.

5.It is needed cuz it puts the text directly on screen?
Sensei
10136 cr points
Send Message: Send PM GB Post
24 / M / The Universe is a...
Offline
Posted 8/6/08
I'm getting the hang of it HAHA!
First  Prev  1  2  3  4  5  Next  Last
You must be logged in to post.