PSP Hacks - Forums
Go Back   PSP Hacks - Forums > Tech Talk > PC Programming

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 05-13-2006, 08:45 PM
Joe88's Avatar
Joe88 Joe88 is offline
Moderator
PSP Titan
 
Join Date: Jun 2005
Location: Staten Island, New York City
Posts: 21,350
Joe88 User Has a Beginner Reputation
Default

I just do it this way :

#include <iostream>
using namespace std;

int main()

{
cout<<"Hello World\n"
}
__________________

[λ] The cake is a lie... [λ]
Reply With Quote
  #12  
Old 05-13-2006, 08:50 PM
PSdonkey's Avatar
PSdonkey PSdonkey is offline
Squirrel Admin
PSP Titan
 
Join Date: Mar 2006
Posts: 9,089
PSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond repute
Default

ok a couple of things that I forgot to put in lesson #1

{ = brace

cout = display message

<< = insert operator

// = one line of comments

/* more than one line of remarks and then */ to close your remarks

\n = make a new line

\t = tab

For example you can have a program like this
-------------------------
#include <iostream.h>
void main()
{
// this is how you make a comment

/* this is how you make
more than one line of comments */

cout<< "Hi there\n";
cout<< "How are you?\n";
}
---------------------------

The \n will create a new line for you so the screen will read

Hi there
How are you?

Without the "\n" then the screen would have shown
Hi thereHow are you?
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here www.psp-hacks.com/forums/viewtopic.php?id=65403
Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/view...693884#p693884
Want to learn how to program C++ ? Check out that tutorial here www.psp-hacks.com/forums/viewtopic.php?id=28694
Reply With Quote
  #13  
Old 05-13-2006, 08:58 PM
PSdonkey's Avatar
PSdonkey PSdonkey is offline
Squirrel Admin
PSP Titan
 
Join Date: Mar 2006
Posts: 9,089
PSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond repute
Default

Yes that is another way to do it joe88 but I wanted to start off as simple as possible for those who don't have any knowledge of C++ yet. Also you forgot the " ; " after your cout statement
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here www.psp-hacks.com/forums/viewtopic.php?id=65403
Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/view...693884#p693884
Want to learn how to program C++ ? Check out that tutorial here www.psp-hacks.com/forums/viewtopic.php?id=28694
Reply With Quote
  #14  
Old 05-13-2006, 09:10 PM
Joe88's Avatar
Joe88 Joe88 is offline
Moderator
PSP Titan
 
Join Date: Jun 2005
Location: Staten Island, New York City
Posts: 21,350
Joe88 User Has a Beginner Reputation
Default

Quote:
Originally Posted by PSdonkey
Yes that is another way to do it joe88 but I wanted to start off as simple as possible for those who don't have any knowledge of C++ yet. Also you forgot the " ; " after your cout statement
:posessed: i have to be more carefull
the complier would have picked up the error.

Guess now its time for cin statments.

int main()
{
int name;

cout<<"plese enter your name\n";
cin>>name;

cout<<"your name is "<<name<<endl;
}
__________________

[λ] The cake is a lie... [λ]
Reply With Quote
  #15  
Old 05-13-2006, 09:27 PM
PSdonkey's Avatar
PSdonkey PSdonkey is offline
Squirrel Admin
PSP Titan
 
Join Date: Mar 2006
Posts: 9,089
PSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond repute
Default

No No No, you are jumping way ahead lol. I haven't even gone over declaring variables yet. Besides, you already made another error. You cant declare name as an interger. It has to be declared as "char" Plus you need to make an array for any name longer then one character. This is how the program would look but everyone else execept joe ignore this for now.

-------------------------
#include <iostream>
using namespace std;
int main()
{
char name[20];
cout<<"Enter your name:\n";
cin>>name;
cout<<"Welcome\t"<<name<<endl;
}
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here www.psp-hacks.com/forums/viewtopic.php?id=65403
Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/view...693884#p693884
Want to learn how to program C++ ? Check out that tutorial here www.psp-hacks.com/forums/viewtopic.php?id=28694
Reply With Quote
  #16  
Old 05-13-2006, 10:23 PM
Joe88's Avatar
Joe88 Joe88 is offline
Moderator
PSP Titan
 
Join Date: Jun 2005
Location: Staten Island, New York City
Posts: 21,350
Joe88 User Has a Beginner Reputation
Default

I know I should have put char....
But I put int.
1 question :
char name[20];
why is there a 20 at the end ? is that the numberes of charaters to store ?
__________________

[λ] The cake is a lie... [λ]
Reply With Quote
  #17  
Old 05-13-2006, 10:33 PM
PSdonkey's Avatar
PSdonkey PSdonkey is offline
Squirrel Admin
PSP Titan
 
Join Date: Mar 2006
Posts: 9,089
PSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond repute
Default

It's called a character array. It is used to store a string of more than one character. "Char" is the data type I used, "name" is the actual array, and [20] is the number of characters you can store into your array. Let me get first get into describing data types and declaring variables before I go too deap into the subject of arrays as probably everyone else here is just getting confused
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here www.psp-hacks.com/forums/viewtopic.php?id=65403
Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/view...693884#p693884
Want to learn how to program C++ ? Check out that tutorial here www.psp-hacks.com/forums/viewtopic.php?id=28694
Reply With Quote
  #18  
Old 05-13-2006, 11:01 PM
PSdonkey's Avatar
PSdonkey PSdonkey is offline
Squirrel Admin
PSP Titan
 
Join Date: Mar 2006
Posts: 9,089
PSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond reputePSdonkey has a reputation beyond repute
Default

ok I will go ahead and start with the second lesson so that others can start to catch up to you joe88.

Variables = 1. letters to store data
2. Must be declared before you can use it.

Data Types = These are what you use to declare your vaiables.

Double - To store number that contain decimal places (23.4453, 7889.00784)(64 bit I believe)
Float - Also to store numbers that contain decimal places(2.54, 67.8) (32 bit I believe)
Int - To store whole numbers (integers) (1,2,3..)
Char - To store characters (A,B,C..)
Bool - Ture or false 0=false 1=true. (Almost no one rally uses this data type)


Math operations

= store
+ add
- subtract
* multiply
/ divide


ok now its time for another program. This program will declare two numbers (5,6) as intergers and also declare two numbers as results (sum, product).

int num1=5; This means that you are declaring "num1" variable to be an integer type and for it's value to be 5.

int sum; This means that you are declaing "sum" variable to be an interger no amtter what is palced inside of it.

sum= num1 + num2; This means that whatever the result of adding the two numbers that were stored into num1 and into num2 will be placed into the variable "sum"

----------------------------
#include <iostream>
using namespace std;
int main()
{
int num1=5;
int num2=6;
int sum;
int product;
sum = num1 + num2;
product = num1 * num2;
cout<< "Sum = "<<sum<<"\n";
cout<< "Product = "<<product<<"\n";
}
---------------------------
After compiling your program, you should get a message on your screen that says
Sum = 11
Product = 30

Now you guys should try to make a program that has three numbers (3.5,2.4,7.8) and find the sum, product, and average of all three numbers. As a hint, use "float" or "double" as your data type since now you are using decimals.
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here www.psp-hacks.com/forums/viewtopic.php?id=65403
Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/view...693884#p693884
Want to learn how to program C++ ? Check out that tutorial here www.psp-hacks.com/forums/viewtopic.php?id=28694
Reply With Quote
  #19  
Old 05-14-2006, 05:10 AM
Yessy Yessy is offline
PSP Guru
 
Join Date: Dec 2005
Posts: 2,472
Yessy User Has a Beginner Reputation
Default

This post was posted by me then edited by me. Thus I feel ashamed of my own stuped kitty posts.
Reply With Quote
  #20  
Old 05-14-2006, 06:41 AM
sparda sparda is offline
PSP Newbie
 
Join Date: Sep 2005
Location: New York
Posts: 44
sparda User Has a Beginner Reputation
Default

PSPdonkey, you forgot to mention that when declaring CHAR variables with a SINGLE character, you will
have to enclose this variable in double apostrophes ('A'). as opposed to strings which is enclosed in
quotes ("EAT"). for example:

char initial = 'A';

Very important, can be the source of many bugs!...
__________________
Visit - Illfoundedmind.com production studios,
were accepting new members for pspvideo game development. Sparda@illfoundedmind.com
Reply With Quote
Reply

 



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 08:03 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©