QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Consumer > General PC Forums > Everything Windows
The above video goes away if you are a member and logged in, so log in now!

c++ coding

This is a discussion on c++ coding within the Everything Windows forums, part of the General PC Forums category; hey im having some problems with this code Spoiler for Code : int main() { int x; int name; cout ...

Closed Thread
 
LinkBack Thread Tools
Old 12-10-2007, 05:29 PM   #1
 

 
Join Date: Oct 2006
Posts: 432
Trader Feedback: 0
Default c++ coding

hey im having some problems with this code
Spoiler for Code:
int main()
{ int x;
int name;
cout << "Hello and welcome to Planet Wars" << endl;

cout << " 1= new player " << endl;
cout << " 2= info " << endl;
cin >> x ;
if (x == 1)
{
cout << "You have chosen to be a new player"<< endl;
cout << "Please enter your name." << endl;
cin >> name;
if (name== 0)
cout << "your name is" << name <<endl;
cout << name << "please press enter to end." <<endl;

// at this point in the script it just ends. what should i put to make it pause. i have more script , but i just didnt show it. the rest of the script works, i just need to no how to pause the screen so it doesnt just end it.

}
Blackbelttcon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 05:33 PM   #2
banned 4 LIFE
 
Join Date: Apr 2007
Location: Jupiter
Posts: 3
Trader Feedback: 0
Default

Do you need "if (name== 0)"?

About the pausing, maybe
Code:
system("PAUSE");
But, I don't really know that much....
explosions is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 05:38 PM   #3
 

 
Join Date: Oct 2006
Posts: 432
Trader Feedback: 0
Default

yea i changed that to

if(name>0)

and that checks if the name is greaterthen 0
-= Double Post =-
o wiat i guess u dont need it

Last edited by Blackbelttcon; 12-10-2007 at 05:39 PM.. Reason: Automerged Doublepost
Blackbelttcon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 05:40 PM   #4
banned 4 LIFE
 
Join Date: Apr 2007
Location: Jupiter
Posts: 3
Trader Feedback: 0
Default

Quote:
Originally Posted by Blackbelttcon
yea i changed that to

if(name>0)

and that checks if the name is greaterthen 0
You made the name a number? 0_o But why don't you remove that line?
explosions is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 05:40 PM   #5
 

 
Join Date: Oct 2006
Posts: 432
Trader Feedback: 0
Default

ok its changed, but it still just ends the script. i want it to pause for like 2 seconds then continue on
-= Double Post =-
yea that system pause worked thanx

Last edited by Blackbelttcon; 12-10-2007 at 05:44 PM.. Reason: Automerged Doublepost
Blackbelttcon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 05:49 PM   #6
banned 4 LIFE
 
Join Date: Apr 2007
Location: Jupiter
Posts: 3
Trader Feedback: 0
Default

Quote:
Originally Posted by Blackbelttcon
ok its changed, but it still just ends the script. i want it to pause for like 2 seconds then continue on
-= Double Post =-
yea that system pause worked thanx
No prob.
explosions is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 05:56 PM   #7
 

 
Join Date: Oct 2006
Posts: 432
Trader Feedback: 0
Default

i am having another problem. everytime the name is equal to a letter not a number the script cancels, but when the name is a number it is just fine.
Blackbelttcon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 06:08 PM   #8
 

 
Join Date: Jul 2006
Location: BEHIND YOU!!
Posts: 1,061
Trader Feedback: 0
Default

You are better off going to another forum for coding on the pc. There is not many people that come here for other things besides the psp.
__________________
[url=http://xs.to][img]http://xs313.xs.to/xs313/07106/wmnp8z.png[/img][/url]

What's a recovery.elf
[QUOTE=iball]
He's the one that fixes Santa's sleigh when it breaks down[/QUOTE]

[QUOTE=Deturbanator]why are we allowed to see the whole flesh and being of the boob but we MUST blur out the tit?[/QUOTE]
[PRE][B]sg57 i love you for turning on the light of homebrew when i was in the darkness of sony[/b][/pre]
psp11 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 06:25 PM   #9
 

 
Join Date: Oct 2006
Posts: 432
Trader Feedback: 0
Default

were is that forum i cant find it.
Blackbelttcon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 06:26 PM   #10
banned 4 LIFE
 
Join Date: Apr 2007
Location: Jupiter
Posts: 3
Trader Feedback: 0
Default

Quote:
Originally Posted by Blackbelttcon
i am having another problem. everytime the name is equal to a letter not a number the script cancels, but when the name is a number it is just fine.
int name;

I don't think you can store letters in that.....
explosions is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 06:39 PM   #11
No longer a community member.
 
Join Date: Dec 2005
Posts: 22
Trader Feedback: 0
Default

You can't store letters in an integer

At the start of your code, under the part where you include the iostream, put:
PHP Code:
#include <string>
Then, make the name variable a string:
PHP Code:
String name;
Hardrive is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-10-2007, 07:50 PM   #12
 

 
Join Date: Jul 2006
Location: BEHIND YOU!!
Posts: 1,061
Trader Feedback: 0
Default

Quote:
Originally Posted by Blackbelttcon
were is that forum i cant find it.
An entirely different forum that's not on qj. Look around for one you like.
__________________
[url=http://xs.to][img]http://xs313.xs.to/xs313/07106/wmnp8z.png[/img][/url]

What's a recovery.elf
[QUOTE=iball]
He's the one that fixes Santa's sleigh when it breaks down[/QUOTE]

[QUOTE=Deturbanator]why are we allowed to see the whole flesh and being of the boob but we MUST blur out the tit?[/QUOTE]
[PRE][B]sg57 i love you for turning on the light of homebrew when i was in the darkness of sony[/b][/pre]
psp11 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-11-2007, 12:42 PM   #13
 

 
Join Date: Oct 2006
Posts: 432
Trader Feedback: 0
Default

alright thanx ill try it out
-= Double Post =-
yea it works thanx
-= Double Post =-
hey one more thing. is there a way to save the name variable and the pass variable into a text document or something, so it is saved

Last edited by Blackbelttcon; 12-11-2007 at 12:46 PM.. Reason: Automerged Doublepost
Blackbelttcon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-11-2007, 01:36 PM   #14
No longer a community member.
 
Join Date: Dec 2005
Posts: 22
Trader Feedback: 0
Default

USE GOOGLE!!!

C and C++ File Manipulation
Hardrive is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-11-2007, 01:54 PM   #15
 

 
Join Date: Oct 2006
Posts: 432
Trader Feedback: 0
Default

thanx, and i have tryed
-= Double Post =-
ok i have a error now and it wont let me compile the app.

Spoiler for code:
cout << name << " you need a password. please type your password below." <<endl;
cin >> pass;
cout << "Is your password " << pass << " y/n" <<endl;
cin >> choice1;
if (choice1 == yes ) //: this is were the error is. 'yes' is underclared (first use this function. that is the error.

what is wrong


{
cout << " Good Then lets begin. What is your gender. Male or Female." <<endl;
cin >> gender;
cout << " Ok Now pick your race. You can be a Human " << gender << " or a lizardcreature " <<endl;
cin>> race
cout << " You are now a " << race << " please wait while we save your infomation." <<endl;
}

Last edited by Blackbelttcon; 12-11-2007 at 02:03 PM.. Reason: Automerged Doublepost
Blackbelttcon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-11-2007, 02:31 PM   #16
No longer a community member.
 
Join Date: Dec 2005
Posts: 22
Trader Feedback: 0
Default

You really need to pick up a book or something. These are the easiest mistakes EVER, it's just like you're copy and pasting code.

If you're evaluting a String, you have to use quotes:
PHP Code:
String example="You need to get a book";
Therefore, in your example:
PHP Code:
if (choice1 == "yes") //This is assuming that you defined choice1 as a String earlier
Hardrive is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-11-2007, 02:44 PM   #17
 

 
Join Date: Oct 2006
Posts: 432
Trader Feedback: 0
Default

alright srry im a little low on cash atm, but im getting next check in a week, so i should be able to get one then.

and one last thing. can i change text color, and if so how.
Blackbelttcon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-11-2007, 03:09 PM   #18
 
kibbles's Avatar
 
Join Date: Jun 2005
Location: |~AZEROTH~|
Posts: 3,601
Trader Feedback: 0
Default

Quote:
Originally Posted by Blackbelttcon
alright srry im a little low on cash atm, but im getting next check in a week, so i should be able to get one then.

and one last thing. can i change text color, and if so how.
google. honestly if your not ready, read a intro book or something (or download one)
__________________
[CENTER][SIZE="3"][FONT="Comic Sans MS"][URL="http://forums.qj.net/f-qjnet-news-and-help-25/t--posting-guidelines-updated-04-04-07--73115.html"] [COLOR="Lime"]| Posting Guidelines | [/COLOR][/URL] [URL="http://forums.qj.net/f-qjnet-news-and-help-25/t--piracy-policy-updated-dec-28-2006--4394.html"][COLOR="Lime"]Piracy Policy | [/COLOR][/URL] [URL="http://forums.qj.net/f-qjnet-news-and-help-25/t-operation-positive-posting-73114.html"][COLOR="Lime"]Operation: Positive Posting | [/COLOR][/URL] [URL="http://forums.qj.net/f-qjnet-news-and-help-25/t-qj-quick-justice-policy-must-read-69509.html"][COLOR="Lime"]Quick Justice Policy | [/COLOR][/URL][/FONT][/SIZE]

[IMG]http://sigs.guildlaunch.net/wsig.php/1813305VpsDo.png[/IMG]

[IMG]http://img523.imageshack.us/img523/2470/towleiieesighw8.gif[/IMG][/CENTER]
kibbles is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-11-2007, 03:26 PM   #19
 

 
Join Date: Oct 2006
Posts: 432
Trader Feedback: 0
Default

i am ready i just have some little questions.

isnt that wut this forums is about.
Blackbelttcon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-11-2007, 04:51 PM   #20
No longer a community member.
 
Join Date: Dec 2005
Posts: 22
Trader Feedback: 0
Default

Forums are about getting help, but not getting help on things that are readily available for free with a five second google search!

BTW, you can't change the text color without moving out of the console realm, which is way ahead of you right now.

Strapped for cash? Go through each of these in order:
[link]
Hardrive is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-11-2007, 05:13 PM   #21
 
FreePlay's Avatar
 
Join Date: Dec 2005
Location: h0000000rj
Posts: 12,858
Trader Feedback: 0
Default

Quote:
Originally Posted by Blackbelttcon
isnt that wut this forums is about.
No, it's about
Quote:
Hard/Software and Windows Discussion
.
__________________
[qj now fails.]
FreePlay is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-11-2007, 06:56 PM   #22
 

 
Join Date: Oct 2006
Posts: 432
Trader Feedback: 0
Default

can a mod close this its getting off topic.
Blackbelttcon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Tags
coding

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 02:42 PM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us