Go Back   Flash Flash Revolution > General Discussion > Chit Chat
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
Old 09-15-2005, 07:08 PM   #21
QreepyBORIS
FFR Player
 
QreepyBORIS's Avatar
 
Join Date: Feb 2003
Location: It is a mystery.
Age: 33
Posts: 7,454
Send a message via AIM to QreepyBORIS Send a message via MSN to QreepyBORIS
Default

Soccr's console idea was right. You can do it Nipunn's way without getting any errors or warnings, but you would probably get some sort of logic error. I tried it in one of my programs, it built fine, but it didn't work. I don't remember if there was another problem or if that was it, though.

In any case, it's just better to use the << or the >> operators with the console instead of commas. For now, at least.

postcount++;
__________________

Signature subject to change.

THE ZERRRRRG.
QreepyBORIS is offline   Reply With Quote
Old 09-15-2005, 07:27 PM   #22
ad0gg
FFR Player
 
Join Date: Dec 2003
Location: At My House
Posts: 989
Default Re: RE: Re: C++ Help

Quote:
Originally Posted by soccr743
Qreepy, you read from the console into the buffer which is in char* format... Then, you would need to convert that to a float in order to use it in calculations.
The function to convert a char * to a float is atof, with its only argument a char * and it returns a value of type float. It is found in in the stdlib.h header file. So you would use it like this:
Code:
#include <iostream>
#include <stdlib>
using namespace std;

int main()
{
        char asdfString[5] = "54.2";
        float asdfFloat;

        asdfFloat = atof(asdfString);

        return 0;
}
...and Voila, you can then use asdfFloat in calculations. The atoi function is exactly the same as the atof function, but it returns an integer value instead.
__________________
ad0gg is offline   Reply With Quote
Old 09-15-2005, 07:44 PM   #23
User6773
Guest
 
Posts: n/a
Default Re: RE: Re: C++ Help

Quote:
Originally Posted by JurseyRider734
The only reason i'm posting is because i'm a day behind in my class. So while everyone is on addictinggames, i'm sitting there confused with this goddamn thing.
Junior year of high school. In my C++ class, we would go to addictinggames and follow links when we were done with our programming project.

I clicked a link called "Flash Flash Revolution" once, on a whim...

...and here I am.
  Reply With Quote
Old 09-15-2005, 11:31 PM   #24
talisman
Resident Penguin
FFR Simfile AuthorFFR Veteran
 
talisman's Avatar
 
Join Date: May 2003
Age: 37
Posts: 4,598
Send a message via AIM to talisman
Default RE: Re: RE: Re: C++ Help

jurs' guido's right on... it just tells you more than you want to know.
talisman is offline   Reply With Quote
Old 09-16-2005, 12:56 AM   #25
GuidoHunter
is against custom titles
Retired StaffFFR Veteran
 
GuidoHunter's Avatar
 
Join Date: Oct 2003
Location: Texas
Age: 39
Posts: 7,371
Send a message via AIM to GuidoHunter Send a message via Skype™ to GuidoHunter
Default RE: Re: RE: Re: C++ Help

Basically, what I wrote is everything you need besides the proper equations. So, if you cut out everything past the precision setting and put in what really needs to be there (I just left chicken's math alone), you'll have a program that does what you want.

--Guido

http://andy.mikee385.com
__________________

Quote:
Originally Posted by Grandiagod View Post
Quote:
Originally Posted by Grandiagod View Post
She has an asshole, in other pics you can see a diaper taped to her dead twin's back.
Sentences I thought I never would have to type.
GuidoHunter is offline   Reply With Quote
Old 09-16-2005, 08:14 AM   #26
Anonymous
FFR Player
 
Join Date: May 2002
Posts: 1,088
Default RE: Re: RE: Re: C++ Help

I entered that, and it wasn't right/there was some kind of error/it's not coded like my other projects. Here's an example of how i'm learning it(a previous project):

Code:
#include <iostream>
using namespace std;

int main()
{
	int years, months, days;
	cout<<"How many years old are you? ";
	cin>>years;
	cout<<endl;
	cout<<"How many months past your years are you? ";
	cin>>months;
	cout<<endl;
	cout<<"How many remaining days old are you? ";
	cin>>days;
	cout<<endl;
	cout<<"The numbers you entered are "<<years<<" for years, "<<months<<" for remaining months, and "<<days<<" for days. ";
	cout<<endl;
	int totalMonths, totalDays;
	totalMonths=years*12+months;
	totalDays=years*360+days;
	cout<<"You are approximately "<<totalMonths<<" months old. ";
	cout<<endl;
	cout<<"You are approximately "<<totalDays<<" days old. ";
	cout<<endl;

	return 0;
}
Anonymous is offline   Reply With Quote
Old 09-16-2005, 08:41 AM   #27
GuidoHunter
is against custom titles
Retired StaffFFR Veteran
 
GuidoHunter's Avatar
 
Join Date: Oct 2003
Location: Texas
Age: 39
Posts: 7,371
Send a message via AIM to GuidoHunter Send a message via Skype™ to GuidoHunter
Default RE: Re: RE: Re: C++ Help

So just move my code around. The only thing that's structurally different from what you just posted and what I posted is you using int main() and me using void main(), which won't make a difference and you shouldn't worry about (unless you're returning 0 in void main or something).

Like I said, rearrange all of my body however you wish to follow whatever format you want. You say what I posted isn't coded like your older project, but I don't see a difference that would matter.

If you got a syntax error, tell us what it is.

--Guido

http://andy.mikee385.com
__________________

Quote:
Originally Posted by Grandiagod View Post
Quote:
Originally Posted by Grandiagod View Post
She has an asshole, in other pics you can see a diaper taped to her dead twin's back.
Sentences I thought I never would have to type.
GuidoHunter is offline   Reply With Quote
Old 09-16-2005, 03:39 PM   #28
QreepyBORIS
FFR Player
 
QreepyBORIS's Avatar
 
Join Date: Feb 2003
Location: It is a mystery.
Age: 33
Posts: 7,454
Send a message via AIM to QreepyBORIS Send a message via MSN to QreepyBORIS
Default RE: Re: RE: Re: C++ Help

How could they not get an error with code like that? They never declared any variables. XD

I would imagine that they would, though.
__________________

Signature subject to change.

THE ZERRRRRG.
QreepyBORIS is offline   Reply With Quote
Old 10-6-2005, 03:16 PM   #29
JurseyRider734
lil j the bad b-word
Retired StaffFFR Veteran
 
JurseyRider734's Avatar
 
Join Date: Aug 2003
Location: nj
Age: 34
Posts: 7,506
Send a message via AIM to JurseyRider734 Send a message via Skype™ to JurseyRider734
Default RE: Re: RE: Re: C++ Help

Hi again. I need help with some other program...I have what I did saved on floppy disk but I forgot that I don't have a floppy drive >_>

Anyways, I use Microsoft Visual Basic thing...so that's what it has to input into. Here's the thing.

Write a program that prompts the user to input x-y coordinate of a point in a Cartesian Plane. The program should output a message indicating whether the point is on the origin, x or y axis, or in a particular quadrant.

I'm pretty sure you have to do the if stuff, etc. Anyone who can help me do it for my class tomorrow morning gets a present >_>
__________________
Quote:
Originally Posted by Arch0wl
I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

Quote:
Originally Posted by Afrobean View Post
Quote:
Originally Posted by JurseyRider734
the fact that you're resorting to threatening physical violence says a lot anyway.
Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.
JurseyRider734 is offline   Reply With Quote
Old 10-6-2005, 03:28 PM   #30
talisman
Resident Penguin
FFR Simfile AuthorFFR Veteran
 
talisman's Avatar
 
Join Date: May 2003
Age: 37
Posts: 4,598
Send a message via AIM to talisman
Default RE: Re: RE: Re: C++ Help

uh here's the logic, not the language:

input x, input y
if x==0 and y==o
then output "origin"
if x==0 and y!=0
then output "x-axis"
if y==0 and x!=0
then output "y-axis"
if x > 0 and y > 0
then output "first quadrant"
if x < 0 and y > 0
then output "second quadrant"
if x<0 and y<0
then output "third quadrant"
if x>0 and y<0 then output "fourth quadrant"

fairly tedious. I'm sure there's a sexier way to do it.
talisman is offline   Reply With Quote
Old 10-6-2005, 05:59 PM   #31
soccr743
FFR Player
Retired Staff
 
soccr743's Avatar
 
Join Date: Dec 2003
Posts: 549
Send a message via AIM to soccr743 Send a message via MSN to soccr743 Send a message via Yahoo to soccr743
Default RE: Re: RE: Re: C++ Help

You messed up your logic for the x and y axis stuff...

Should be:

input x, input y
if x==0 and y==0
then output "origin"
else if x==0 and y!=0
then output "y-axis"
else if y==0 and x!=0
then output "x-axis"
else if x > 0 and y > 0
then output "first quadrant"
else if x < 0 and y > 0
then output "second quadrant"
else if x<0 and y<0
then output "third quadrant"
else if x>0 and y<0 then output "fourth quadrant"

That is far from tedious as far as code goes...

-----Soccr743-----
__________________
soccr743 is offline   Reply With Quote
Old 10-6-2005, 07:25 PM   #32
talisman
Resident Penguin
FFR Simfile AuthorFFR Veteran
 
talisman's Avatar
 
Join Date: May 2003
Age: 37
Posts: 4,598
Send a message via AIM to talisman
Default RE: Re: RE: Re: C++ Help

oh yeah. ::
talisman is offline   Reply With Quote
Old 10-6-2005, 08:35 PM   #33
chickendude
Away from Computer
FFR Simfile AuthorFFR Veteran
 
chickendude's Avatar
 
Join Date: Sep 2003
Location: Massachusetts
Age: 33
Posts: 1,901
Send a message via AIM to chickendude
Default RE: Re: RE: Re: C++ Help

Code:
#include <iostream>
main()
{
 int x,y;

 cout << "enter an x and a y";
 cin >> x;
 cin >> y;
 if x==0 && y==0
    cout << "origin";
 if x==0 && y!=0
    cout << "y-axis";
 if y==0 && x!=0
    cout << "x-axis";
 if x > 0 && y > 0
    cout << "first quadrant";
 if x < 0 && y > 0
    cout << "second quadrant";
 if x<0 && y<0
    cout << "third quadrant";
 if x>0 && y<0 
    cout << "fourth quadrant" ;
}
did I win?


Edit for bad include syntax <_<
__________________
chickendude is offline   Reply With Quote
Old 10-6-2005, 09:30 PM   #34
talisman
Resident Penguin
FFR Simfile AuthorFFR Veteran
 
talisman's Avatar
 
Join Date: May 2003
Age: 37
Posts: 4,598
Send a message via AIM to talisman
Default RE: Re: RE: Re: C++ Help

you forgot the most important part.

I'll let you try to figure out where it is...
talisman is offline   Reply With Quote
Old 10-6-2005, 09:36 PM   #35
QreepyBORIS
FFR Player
 
QreepyBORIS's Avatar
 
Join Date: Feb 2003
Location: It is a mystery.
Age: 33
Posts: 7,454
Send a message via AIM to QreepyBORIS Send a message via MSN to QreepyBORIS
Default RE: Re: RE: Re: C++ Help

Gosh, I can't figure it out, Talis (or can I?).

If you read that sentence above and you have a brain, you'd know I know what the errors would be.

Oh, snap, I read the code again and there's actually another, much more glaring error in Nipunn's code. How could you, man? I always add that in first.

Also, you should declare a namespace. It's a good practice.


Also, you should make x and y doubles, then ask for their input on the same line (as in, cin >> x >> y. You just need a space between the two numbers when you input them.

Also, you should use newlines and grammar to spice it up.
__________________

Signature subject to change.

THE ZERRRRRG.
QreepyBORIS is offline   Reply With Quote
Old 10-6-2005, 09:52 PM   #36
chickendude
Away from Computer
FFR Simfile AuthorFFR Veteran
 
chickendude's Avatar
 
Join Date: Sep 2003
Location: Massachusetts
Age: 33
Posts: 1,901
Send a message via AIM to chickendude
Default Re: RE: Re: RE: Re: C++ Help

Code:
#include <iostream>
main()
{
 using std::namespace
 int x,y;

 cout << "enter an x and a y";
 cin >> x >> y;
 if x==0 && y==0
    cout << "origin";
 if x==0 && y!=0
    cout << "y-axis";
 if y==0 && x!=0
    cout << "x-axis";
 if x > 0 && y > 0
    cout << "first quadrant";
 if x < 0 && y > 0
    cout << "second quadrant";
 if x<0 && y<0
    cout << "third quadrant";
 if x>0 && y<0 
    cout << "fourth quadrant" ;
}
ok std::namespace
and cin both on the same line
I stole all the words from talisman/sccr
plus I forget how to newline >_> is it like std::endl or can I just cout a "\n"
__________________
chickendude is offline   Reply With Quote
Old 10-6-2005, 10:20 PM   #37
QreepyBORIS
FFR Player
 
QreepyBORIS's Avatar
 
Join Date: Feb 2003
Location: It is a mystery.
Age: 33
Posts: 7,454
Send a message via AIM to QreepyBORIS Send a message via MSN to QreepyBORIS
Default RE: Re: RE: Re: RE: Re: C++ Help

You can newline two ways.

Here is and example of each:

cout << "Cock goes where?\n";
cout << "Cock goes over there. -->" << endl;

Okay.

By the way, you should probably stick the namespace right under your includes. It's just easier than sticking it into every single function in the program.

And since you missed it: You forgot to return 0! You also forgot to put parentheses around your conditionals. Shame, man. :P
__________________

Signature subject to change.

THE ZERRRRRG.
QreepyBORIS is offline   Reply With Quote
Old 10-6-2005, 10:45 PM   #38
GuidoHunter
is against custom titles
Retired StaffFFR Veteran
 
GuidoHunter's Avatar
 
Join Date: Oct 2003
Location: Texas
Age: 39
Posts: 7,371
Send a message via AIM to GuidoHunter Send a message via Skype™ to GuidoHunter
Default Re: RE: Re: RE: Re: C++ Help

Code:
#include <iostream>
using namespace std;

void main()
{
 double x,y;

 cout << "enter an x and a y";
 cin >> x;
 cin >> y;
 if x==0 && y==0
    cout << "origin";
 if x==0 && y!=0
    cout << "y-axis";
 if y==0 && x!=0
    cout << "x-axis";
 if x > 0 && y > 0
    cout << "first quadrant";
 if x < 0 && y > 0
    cout << "second quadrant";
 if x<0 && y<0
    cout << "third quadrant";
 if x>0 && y<0 
    cout << "fourth quadrant" ;
}
Assuming you don't need parentheses around the conditional statements (which I always just put), that code'll work.

--Guido

http://andy.mikee385.com
__________________

Quote:
Originally Posted by Grandiagod View Post
Quote:
Originally Posted by Grandiagod View Post
She has an asshole, in other pics you can see a diaper taped to her dead twin's back.
Sentences I thought I never would have to type.
GuidoHunter is offline   Reply With Quote
Old 10-6-2005, 11:26 PM   #39
talisman
Resident Penguin
FFR Simfile AuthorFFR Veteran
 
talisman's Avatar
 
Join Date: May 2003
Age: 37
Posts: 4,598
Send a message via AIM to talisman
Default RE: Re: RE: Re: RE: Re: C++ Help

yeah... I was going for the return 0; part... otherwise any half decent compiler will rape you if you try to make it compile that code.
talisman is offline   Reply With Quote
Old 10-7-2005, 02:43 PM   #40
chickendude
Away from Computer
FFR Simfile AuthorFFR Veteran
 
chickendude's Avatar
 
Join Date: Sep 2003
Location: Massachusetts
Age: 33
Posts: 1,901
Send a message via AIM to chickendude
Default Re: RE: Re: RE: Re: C++ Help

Code:
#include <iostream>
main()
{
 using std::namespace
 int x,y;

 cout << "enter an x and a y \n";
 cin >> x >> y;
 if (x==0 && y==0)
    cout << "origin";
 if (x==0 && y!=0)
    cout << "y-axis";
 if (y==0 && x!=0)
    cout << "x-axis";
 if (x > 0 && y > 0)
    cout << "first quadrant";
 if (x < 0 && y > 0)
    cout << "second quadrant";
 if (x<0 && y<0)
    cout << "third quadrant";
 if (x>0 && y<0)
    cout << "fourth quadrant" ;
}
ok stupid conditionals parentheses >_<
silly me
anyway, even though its too late I feel the need to fix it

you can do a main without a return I believe.
__________________
chickendude is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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 -5. The time now is 08:06 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright FlashFlashRevolution