PSP3D Left Header
PSP3D Header Right
PSP3D Logo CraveOnline Logo
Help the PSP 3D community grow!
Vote for us below:


Vote on the PSP Top 200
PSP Top 200 - Games, Videos, Wallpapers, Files, Hacks, Homebrew

Development Center - Learn the basics of coding or talk about advanced coding techniques with other developers.

Welcome to PSP3D.com - Sony PlayStation Portable News, Homebrew, Hacks, Reviews, Videos, Mods, Forums!

You are currently viewing our website as a guest, which gives you limited access to reply and interact to discussions and other members. By joining our free community, you will be able to post topics in the forums, communicate privately with other members, vote in polls, and access many other special features.

Registration is fast, simple, and absolutely free so join our community today!

Go Back PSP3D.com - Sony PlayStation Portable News, Homebrew, Hacks, Reviews, Videos, Mods, Forums > PSP Forums > Development Center
Tags: code


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-30-2007, 02:03 PM
dq9's Avatar
dq9 dq9 is offline
Moderator
My Mood:
 
Join Date: Jun 2006
Location: Iacon, Cybertron
Age: 20
Posts: 2,385
Points: 440,666.30
Donate
Send a message via AIM to dq9 Send a message via Yahoo to dq9
Need help with my code!

I am trying to learn C++ and I am trying to make an app where it has you type in two names and then it says name1 has a crush on name2. But my code isn't working right. Can you guys take a look at it and help me out?

Code:
#include using namespace std; int main() { int name1; int name2; cout<<"Type a name: "; cin>> name1; cout<<"Type another name: "; cin>> name2; cout<<"Guess what?" << name1 <<"has a crush on "<< name2 <<"\n"; return 0; }
__________________
| Rules | Downgrade Tutorial |
| Guidelines for creating News | Guidelines for Reviewing Games |
My Forum
Look for me on Xbox Live. My gamertag is dq9.


VOTE FOR PSP3d!!!
One vote every day makes all the difference in the world!
Reply With Quote
  #2 (permalink)  
Old 08-30-2007, 03:14 PM
iamstrange14's Avatar
iamstrange14 iamstrange14 is offline
PSP3D's Strangest Member
My Mood:
 
Join Date: Nov 2005
Location: Ca$hville
Age: 16
Posts: 775
Points: 3.44
Donate
Send a message via AIM to iamstrange14 Send a message via ShopTapNham to iamstrange14 Send a message via Yahoo to iamstrange14
you need a cin.get(); or cin.ignore(); i think
__________________
Think outside the cubical triangle

wilhel1812 is my hero!

Join my site! http://uberforumz.com

Thanks to pspkillsds for 250 points!
Thanks to zzaz3 for 59,000 points!


Reply With Quote
  #3 (permalink)  
Old 08-30-2007, 03:39 PM
dq9's Avatar
dq9 dq9 is offline
Moderator
My Mood:
 
Join Date: Jun 2006
Location: Iacon, Cybertron
Age: 20
Posts: 2,385
Points: 440,666.30
Donate
Send a message via AIM to dq9 Send a message via Yahoo to dq9
I had those in, but it didn't make a difference. What do those do any way, I just copied code from a tutorial site and messed around with it.

EDIT: I added in the cin.ignore(); codes and the cin.get(); too. It will compile with and with out them, but when I go to use the program it just displays this:

Code:
Last login: Thu Aug 30 14:46:33 on ttyp1 Welcome to Darwin! 172:~ jeff$ /Users/jeff/Desktop/programs/enter/enter1; exit Type a name: jeff Type another name: Guess what?-1880832560has a crush on -1073743208 logout [Process completed]
I am opening this through Terminal (on OS X) and compiling it in the same app.

Here is the source now:

Code:
#include using namespace std; int main() { int name1; int name2; cout<<"Type a name: "; cin>> name1; cin.ignore(); cout<<"Type another name: "; cin>> name2; cin.ignore(); cout<<"Guess what?" << name1 <<"has a crush on "<< name2 <<"\n"; cin.get(); return 0; }
__________________
| Rules | Downgrade Tutorial |
| Guidelines for creating News | Guidelines for Reviewing Games |
My Forum
Look for me on Xbox Live. My gamertag is dq9.


VOTE FOR PSP3d!!!
One vote every day makes all the difference in the world!

Last edited by dq9 : 08-30-2007 at 03:50 PM.
Reply With Quote
  #4 (permalink)  
Old 08-30-2007, 04:35 PM
pspkillsds's Avatar
pspkillsds pspkillsds is offline
Senior Member
 
Join Date: Dec 2005
Location: flash0:/vsh/resource
Posts: 1,037
Points: 4.88
Donate
Send a message via ICQ to pspkillsds Send a message via AIM to pspkillsds Send a message via ShopTapNham to pspkillsds Send a message via Yahoo to pspkillsds
p00p .
__________________
Help me out;
Sign up for pictureyourprize.com and put ThomasTerror904 in the referral thing. :]
Reply With Quote
  #5 (permalink)  
Old 08-30-2007, 07:37 PM
iamstrange14's Avatar
iamstrange14 iamstrange14 is offline
PSP3D's Strangest Member
My Mood:
 
Join Date: Nov 2005
Location: Ca$hville
Age: 16
Posts: 775
Points: 3.44
Donate
Send a message via AIM to iamstrange14 Send a message via ShopTapNham to iamstrange14 Send a message via Yahoo to iamstrange14
try changeing the variables to 1 and 2
__________________
Think outside the cubical triangle

wilhel1812 is my hero!

Join my site! http://uberforumz.com

Thanks to pspkillsds for 250 points!
Thanks to zzaz3 for 59,000 points!


Reply With Quote
  #6 (permalink)  
Old 08-30-2007, 08:45 PM
dq9's Avatar
dq9 dq9 is offline
Moderator
My Mood:
 
Join Date: Jun 2006
Location: Iacon, Cybertron
Age: 20
Posts: 2,385
Points: 440,666.30
Donate
Send a message via AIM to dq9 Send a message via Yahoo to dq9
Code:
172:~/Desktop/programs/enter jeff$ g++ -o enter1 enter1.cpp enter1.cpp: In function 'int main()': enter1.cpp:12: error: expected unqualified-id before numeric constant enter1.cpp:13: error: expected unqualified-id before numeric constant enter1.cpp:16: error: ambiguous overload for 'operator>>' in 'std::cin >> 1' /usr/include/c++/4.0.0/istream:131: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits] /usr/include/c++/4.0.0/istream:134: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits] /usr/include/c++/4.0.0/istream:137: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits] /usr/include/c++/4.0.0/istream:230: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits] enter1.cpp:19: error: ambiguous overload for 'operator>>' in 'std::cin >> 2' /usr/include/c++/4.0.0/istream:131: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits] /usr/include/c++/4.0.0/istream:134: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits] /usr/include/c++/4.0.0/istream:137: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits] /usr/include/c++/4.0.0/istream:230: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits]
This is what I for when I tried to compile it.

Here is my source code now:

Code:
#include using namespace std; int main() { int 1; int 2; cout<<"Type a name: "; cin>> 1; cin.ignore(); cout<<"Type another name: "; cin>> 2; cin.ignore(); cout<<"Guess what?" << 1 <<"has a crush on "<< 2 <<"\n"; cin.get(); return 0; }
Are my arrows pointing the right way in the
Code:
cout<<"Guess what?" << 1 <<"has a crush on "<< 2 <<"\n";
line?
__________________
| Rules | Downgrade Tutorial |
| Guidelines for creating News | Guidelines for Reviewing Games |
My Forum
Look for me on Xbox Live. My gamertag is dq9.


VOTE FOR PSP3d!!!
One vote every day makes all the difference in the world!
Reply With Quote
  #7 (permalink)  
Old 08-31-2007, 01:13 AM
iamstrange14's Avatar
iamstrange14 iamstrange14 is offline
PSP3D's Strangest Member
My Mood:
 
Join Date: Nov 2005
Location: Ca$hville
Age: 16
Posts: 775
Points: 3.44
Donate
Send a message via AIM to iamstrange14 Send a message via ShopTapNham to iamstrange14 Send a message via Yahoo to iamstrange14
think i figured it out- you need a char because you cant store letters in variables
__________________
Think outside the cubical triangle

wilhel1812 is my hero!

Join my site! http://uberforumz.com

Thanks to pspkillsds for 250 points!
Thanks to zzaz3 for 59,000 points!



Last edited by iamstrange14 : 08-31-2007 at 01:15 AM.
Reply With Quote
  #8 (permalink)  
Old 08-31-2007, 11:25 AM
pspkillsds's Avatar
pspkillsds pspkillsds is offline
Senior Member
 
Join Date: Dec 2005
Location: flash0:/vsh/resource
Posts: 1,037
Points: 4.88
Donate
Send a message via ICQ to pspkillsds Send a message via AIM to pspkillsds Send a message via ShopTapNham to pspkillsds Send a message via Yahoo to pspkillsds
I know my reply helped alot.
__________________
Help me out;
Sign up for pictureyourprize.com and put ThomasTerror904 in the referral thing. :]
Reply With Quote
  #9 (permalink)  
Old 08-31-2007, 01:41 PM
dq9's Avatar
dq9 dq9 is offline
Moderator
My Mood:
 
Join Date: Jun 2006
Location: Iacon, Cybertron
Age: 20
Posts: 2,385
Points: 440,666.30
Donate
Send a message via AIM to dq9 Send a message via Yahoo to dq9
Indeed it did pspkillsds.

iamstrange14: What is a char? Don't forget, I am still learning and don't know to much yet. And thanks for all of your help so far.

EDIT: my girlfriend came to the rescue. Here is my new code (that works):

Code:
#include #include using namespace std; int main() { string name1; string name2; cout<<"Type a name: "; cin>>name1; cin.ignore(); cout<<"Type another name: "; cin>> name2; cin.ignore(); cout<<"Guess what? " << name1 <<" has a crush on "<< name2 <<"\n"; cin.get(); return 0; }
__________________
| Rules | Downgrade Tutorial |
| Guidelines for creating News | Guidelines for Reviewing Games |
My Forum
Look for me on Xbox Live. My gamertag is dq9.


VOTE FOR PSP3d!!!
One vote every day makes all the difference in the world!

Last edited by dq9 : 08-31-2007 at 06:20 PM.
Reply With Quote
  #10 (permalink)  
Old 08-31-2007, 06:52 PM
iamstrange14's Avatar
iamstrange14 iamstrange14 is offline
PSP3D's Strangest Member
My Mood:
 
Join Date: Nov 2005
Location: Ca$hville
Age: 16
Posts: 775
Points: 3.44
Donate
Send a message via AIM to iamstrange14 Send a message via ShopTapNham to iamstrange14 Send a message via Yahoo to iamstrange14
so it looks like you left out an include and hads the .get's and .ignore's mixed up? i dont know too much either and i was still learning until i screwed up dev c++
__________________
Think outside the cubical triangle

wilhel1812 is my hero!

Join my site! http://uberforumz.com

Thanks to pspkillsds for 250 points!
Thanks to zzaz3 for 59,000 points!


Reply With Quote
Reply

« Looking to learn programming. | Compiling for PSP on OS X? »



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 0.00
Points Per Thread: 1.00
Points Per Reply: 0.10

Similar Threads
Thread Thread Starter Forum Replies Last Post
SmashGPsp Source Code Released! Robert A. Homepage News 7 07-23-2006 06:35 AM
(PLEASE HELP) how do you... pspkillsds Homebrew/Hacking 8 06-09-2006 01:53 PM
LUA Image Inversion Code Released! Robert A. Homepage News 6 06-04-2006 04:13 AM
parental control code Ben_weinberg General PSP Discussion 2 03-19-2006 01:07 PM
PSP Pin Code?? mirko General PSP Discussion 19 12-19-2005 07:28 AM





Crave Partner Sites: CraveOnline.com | DVDFile.com | PSP3D.com | ComingSoon.net | SuperHeroHype.com | RedBalcony.com |