mega basic c++ problem help mee lol - Overclock.net - An Overclocking Community
Forum Jump: 

mega basic c++ problem help mee lol

Reply
 
Thread Tools
post #1 of 53 (permalink) Old 03-19-2009, 01:59 PM - Thread Starter
New to Overclock.net
 
smokey888's Avatar
 
Join Date: Jan 2009
Location: West Midlands
Posts: 142
Rep: 3 (Unique: 3)
can anyone tel me whats wrong with what i just did i followed it out of a e book? i dont know anything about programming so ye.








/*
an interactive program that computes
the area of a rectangle
/*

#include <iostream>
using namespace std;

int main()
{
int length; // this declares a variable
int width; // this declares another variable

cout <<*Enter the length: ";
cin >> length; // input the length

cout << *Enter the width: ";
cin >> width; //input the width

cout << *The area is ";
cout << length * width; // display the area

return 0;
}

smokey888 is offline  
Sponsored Links
Advertisement
 
post #2 of 53 (permalink) Old 03-19-2009, 02:08 PM - Thread Starter
New to Overclock.net
 
smokey888's Avatar
 
Join Date: Jan 2009
Location: West Midlands
Posts: 142
Rep: 3 (Unique: 3)
anyone?

smokey888 is offline  
post #3 of 53 (permalink) Old 03-19-2009, 02:10 PM
New to Overclock.net
 
[KOD[Redfox's Avatar
 
Join Date: Nov 2007
Location: N. Ireland
Posts: 136
Rep: 9 (Unique: 9)
Hi,

I think it might be because youi ahve used a * after the cout command.

You have written cout <<* Enter the width: ";

It should be cout << "Enter the width: ";

Hope this helps,
Matt



[KOD[Redfox is offline  
Sponsored Links
Advertisement
 
post #4 of 53 (permalink) Old 03-19-2009, 02:11 PM - Thread Starter
New to Overclock.net
 
smokey888's Avatar
 
Join Date: Jan 2009
Location: West Midlands
Posts: 142
Rep: 3 (Unique: 3)
okies ill try tht lol thankss

smokey888 is offline  
post #5 of 53 (permalink) Old 03-19-2009, 02:12 PM - Thread Starter
New to Overclock.net
 
smokey888's Avatar
 
Join Date: Jan 2009
Location: West Midlands
Posts: 142
Rep: 3 (Unique: 3)
/*
an interactive program that computes
the area of a rectangle
/*

#include <iostream>
using namespace std;

int main()
{
int length; // this declares a variable
int width; // this declares another variable

cout << "Enter the length: ";
cin >> "length; // input the length

cout << "Enter the width: ";
cin >> width; //input the width

cout << "The area is ";
cout << length * width; // display the area

return 0;
}





That better? when i debug it ways there are build errors?

smokey888 is offline  
post #6 of 53 (permalink) Old 03-19-2009, 02:15 PM
New to Overclock.net
 
Join Date: Apr 2008
Location: Toronto, Ontario
Posts: 2,688
Rep: 206 (Unique: 178)
I just started C++ too, I'll have a look at that.

Edit:

#include <iostream>
using namespace std;

int main()
{
int length; // this declares a variable
int width; // this declares another variable

cout << "Enter the length: ";
cin >> length ;
cout << "Enter the width: ";
cin >> width; //input the width

cout << "The area is ";
cout << length * width; // display the area
system ("pause");
return 0;
}




This compiles and works, found a mistake where I bolded, and something was messed up in your commenting, worked after I deleted the comments.

system ("pause"); is just so the window did not just close on me right when I entered the last value.

Would be nice to add some units too...

Proud owner of a GPH GP2x Wiz and OpenPandora
Quote:
Originally Posted by DuckieHo go_quote.gif
"Fast, cheap, and good -- pick any two."


Darkknight512 is offline  
post #7 of 53 (permalink) Old 03-19-2009, 02:16 PM
New to Overclock.net
 
66gto's Avatar
 
Join Date: Jul 2006
Posts: 266
Rep: 5 (Unique: 5)
The comment at the beginning....the "/*" at the end should be reversed to "*/"

/*comment*/

like that ^

You might want to get a new eBook if it has errors like that. Unless you copied wrong

66gto is offline  
post #8 of 53 (permalink) Old 03-19-2009, 02:16 PM - Thread Starter
New to Overclock.net
 
smokey888's Avatar
 
Join Date: Jan 2009
Location: West Midlands
Posts: 142
Rep: 3 (Unique: 3)
nice one if u figure it u get a +rep

and u have 666 posts dude

smokey888 is offline  
post #9 of 53 (permalink) Old 03-19-2009, 02:18 PM - Thread Starter
New to Overclock.net
 
smokey888's Avatar
 
Join Date: Jan 2009
Location: West Midlands
Posts: 142
Rep: 3 (Unique: 3)
hmm that changed somthing... now the debug now says

1>.\\area.cpp(6) : warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1> Add directive to 'stdafx.h' or rebuild precompiled header
1>.\\area.cpp(25) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?

smokey888 is offline  
post #10 of 53 (permalink) Old 03-19-2009, 02:20 PM
New to Overclock.net
 
66gto's Avatar
 
Join Date: Jul 2006
Posts: 266
Rep: 5 (Unique: 5)
remove the " before cin >> length.

66gto is offline  
Reply

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the Overclock.net - An Overclocking Community forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may 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