Page 3 of 5

Posted: Sun Nov 28, 2004 10:15 pm
by Falco Girgis
First off, I have no clue what JSL said, but I will enlarge the monstrosity to be able to read after I post this:

Code: Select all

Bwuhahaha!!! I just made you copy-paste a random chunk of text. Hey, at least I'm not posting secret binary messages.
Now, Cobain, the reason for:

Code: Select all

 cin >> DumbyVar; 
Is so that it doesn't flicker like that.

What you are doing is saying that standard (user) input is stored in DumbyVar. So it waits for you to enter something then saves it into DumbyVar. It's not like you're doing anything with that, but it's an easy solution to not flickering. Don't forget to declare DumbyVar either. Somewhere at the top put:

Code: Select all

int DumbyVar;
Haha, I just restated what JSL did. Eat that!
JS Lemming wrote: CURSE "using namespace std;"
AMEN!
Did I ever tell you that I've never used cout in my life? Never once. When I first learned C++, I started right off on Dreamcast (had a hell of a hard time). Now It's SDL. I seriously don't think I've ever done so much as a "Hello World" in a DOS console with C++!
cobain wrote: lol (is it ok to say lol? its abbreviating you know)
JS Lemming wrote: Cobain, I guess you can use lol, BUT it is always best to use "bag". Do you know why? Because it stands for Bust-A-Gut. EAT THAT FOOLS!
OMFG t3h l33+ l0ll0rz WTF my IMHO 2day 4eva FOOLS!

lol, nobody cares if you abreviate like that. Just your whole post gets a little annoying. What really annoys me (you can still do it, I'm just a jerk). Is when people say stuff like 2 and b4 instead of to and before.

Posted: Mon Nov 29, 2004 4:16 pm
by MarauderIIC
cobain wrote:Is this better?
Holy shit yes! Thank you! I can read what you write now! HURRAY!!!

:)

Cobain, to preserve spacing in chunks you post, use [ code ] [ /code ] tags. No spaces of course.

I didn't write "crap" btw, it's all censored and stuff. :)

Posted: Mon Nov 29, 2004 4:25 pm
by cobain
Ok, I understand what int DumbyVar does,but what exactly is it? Is it like copying something to a clipboard or temporarily saving it into a temp folder? Also
CURSE "using namespace std;"
what is that!? was i supposed to put that in my program somewhere? You never specified what that text was for, so I am a little bit confused. Moving right along, I am currently designing a website, cause its been awile and I wish to refresh my memory on syntax stuff. If I download a template, how can i put my own pictures or text on that template? ie. Would I write a HTML document and somehow put the two together so that the HTML text and images appear on top of that template, or would i go into photoshop and change that template? Question 2: Wehn i make a likn (ahref I think, or something like that) I can make on easily enough, but on most websites there is a bar over on the side that has different parts of the website that can be accessed, how can I align all of my links off to the side of my text and have them on buttons? Last, lets say i have an animation in the top center, I would like to put two smaller animations on either side of it, how would I do that? And on a similar note, How can I make text appear exactly(to the pixel) on the page where I want it? I am sorry that doesnt pertain to programming but I wont ask many HTML questions often at all :D [/quote]

Posted: Mon Nov 29, 2004 8:27 pm
by JS Lemming
Ok, I understand what int DumbyVar does,but what exactly is it? Is it like copying something to a clipboard or temporarily saving it into a temp folder?
Your exactly right. All it does is saves the var to a temporary folder so you can use it later.








pffft!!!!!!!!! Sorry guys, I just wanted to see the looks on your faces... until I realized... that's kinda impossible (imagines Gyro posting a pic of his face all disgruntled)...

Naw, I be just kidding. No temp folders for C++, I think you're confusing C++ with Perl. :lol:

Ok Ok. seriously. When you declare a variable, you set aside a piece of memory for whatever you want. Which means you can store values in a variable. What cin does is takes user input via the console box and stores the entered value in the variable.

Eh, I don't even want to explain that stupid namespace crap. Don't worry, its not important now. Just know you need it to use the cout and cin junk. Try to compile this mug (i put the namespace thing in for you).

Code: Select all

#include <stdio.h>
#include <iostream>

using namespace std;

//Declaring an Integer
int Number;

//Program execution starts here
int main(int argc, char *argv[])
{
    //Print out this string to the console
    cout << "Woot Woot! It works! Now enter a number foo!\n";

    //Get input from the user
    cin >> Number;

    //Display what the user entered
    cout << "\n\nYou entered the number " << Number;

    cout << "\n\n\n\nEnter another number and this program will quit.";

    int DumbyVar;
    cin >> DumbyVar;

    //Return to the Operating System!
    return 0;
}
My advice for the HTML. First, take the template and place it on a table. Then grab a can of hair spray from the counter. Next, go to the kitchen and pick up a few matches. Now, hold the hair spray upright pointing at the template. Light a match and push teh button. Finaly, watch as the template is engulfed in flames and slowy dies away. Mission accomplished.

The thing about HTML, also why I hate it, is that you can't make it look the same on each computer. It's just impossible. I could tell you how to do pixel exact placement, but it would only work for IE. If someone saw it in netscape, their poor apple computer would burn mercifulessly. BUT, you can easily make things either appear left, center, or right by doing something like this.

Code: Select all


<font face="verdana" size="4">

<p align="left">
Sup G, I'm on da left.
</p>

<p align="center">
Watch out foo, I'm in teh center.
</p>

<p align="right">
Sigh... I'm just on the right.
</p>
Look into <table> tag for things like more stuff on one line of page... er... I guess thats how you would describe it.

Posted: Mon Nov 29, 2004 8:39 pm
by Falco Girgis
Templates? Naw, if you really want to become a good web-designer (also adds to programmer), you should make your own. Code your own HTML too. Invent your own site looks that are nice.

I'm not saying that TheChaosRift looks great (though I think it does), but the layout is something that JSL and I made. Templates are terrible. I think they're overused nowadays and make the net a boring place! Be creative! Gawd, you should've seen the first copy of TheChaosRift. I had the navigator where putting your mouse over it made sprites appear on the screen. I used FRAMES for bob's sake! I also insulted any Netscape user that entered!

Go all out, make mistakes. Web design isn't about conformity with what some 50 year old web designers think "looks good" (contrary to popular belief).
JS Lemming wrote:pffft!!!!!!!!! Sorry guys, I just wanted to see the looks on your faces... until I realized... that's kinda impossible (imagines Gyro posting a pic of his face all disgruntled)...
BAG! I swear, the minute I read that line, my face did a :watiff:!

I think something else you might be interested in the long run, cobain, is CSS. I personally didn't bother learning it (that's why JSL is here! :lol:), but it's powerful.

Also, to make dynamic things that update and do things without you coding HTML, learn Perl like I did, or PHP like Marauder did.

And for nice client side awesomeness/glory learn JavaScript like JSL is an expert at.

Posted: Tue Nov 30, 2004 6:23 pm
by cobain
Hey guys, this is the first actual program i have written, and none of it came from my book so theres probably MANY errors. Just to let you know these equations are 100% correct, it is for a math thing called Cramer's Rule which is used to solve two equations each of which have two variables. Ex. Ax + By = E and Cx + Dy = F If you dont understand that, I cant help you. But when i compiled this, it hilited the line that said int A; and had a red "X" next to it, I compared it to other correctly written programs and I could find no differences in our "int"s. Any suggestions about any part of the program are appreciated, in fact, I have no clue what I put as the top part, above the {} things, I just copied it exactly from a different C++ program. Help!

Code: Select all

#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[])
int A;
int B;
int E;
int C;
int D;
int F;
int X
int Y;
{
    cout << "Given Ax + By = E and Cx + Dy = F";
    cout << "/n A=?";
    cin >> A;
    cout << "/n B=?";
    cin >> B;
    cout << "/n E=?";
    cin >> E;
    cout << "/n C=?";
    cin >> C;
    cout << "/n D=?";
    cin >> D;
    cout << "/n F=?";
    cin >> F;
    
     X=((ED-BF)/(AD-BC))
     Y=((AF-EC)/(AD-BC))
     cout << "/n X=" << X;
     cout << "/n Y=" << Y;
     return 0;
}     
Do I need semi-colons after the equations? Are they written correctly or do I need spaces between the "X" and "=" and the equation?

Posted: Wed Dec 01, 2004 7:31 am
by JS Lemming
Your problem is that your declaring the ints inbetween a function name and the "{". Try moving them above the main function like so:

Code: Select all

#include <iostream> 
#include <stdlib.h> 

using namespace std; 

int A; 
int B; 
int E; 
int C; 
int D; 
int F; 
int X;
int Y; 

int main(int argc, char *argv[]) 
{ 
    cout << "Given Ax + By = E and Cx + Dy = F"; 
    cout << "/n A=?"; 
    cin >> A; 
    cout << "/n B=?"; 
    cin >> B; 
    cout << "/n E=?"; 
    cin >> E; 
    cout << "/n C=?"; 
    cin >> C; 
    cout << "/n D=?"; 
    cin >> D; 
    cout << "/n F=?"; 
    cin >> F; 
    
     X=((ED-BF)/(AD-BC)); 
     Y=((AF-EC)/(AD-BC)); 
     cout << "/n X=" << X; 
     cout << "/n Y=" << Y; 
     return 0; 
}  

You also have to put semicolns after the equations (i did that above).

Posted: Wed Dec 01, 2004 5:12 pm
by cobain
Hi. I got the program working...in a way. It does work when you put in easy to solve equations, but when the answers are supposed to come out as fractions or decimals, it rounds down. I know this because I wrote this program in my graphing calculator which I have against my own work, and it is flawless. But compile this program, it should have no errors and run it: it will ask for A, B, E, C, D, F which are Ax + By = E and
Cx + Dy = F they will pop up in order, so try running these equations.
5x + -6y = -7 and 9x + 5y = -5 This should mean, when the program is running, put in 5, hit enter, put in 6, hit enter, and so on. The correct answer to this is that x= -65/79 and y= 38/79 The program will say that x=0 and y=0, which is or course incorrect. It is not just this equation, but many that the answers aren't whole numbers. first, how can I make this display the correct answers, and secondly how can I make the comptuer make those decimal answers into fractions? The program is as follows:

Code: Select all

#include <iostream> 
#include <stdlib.h> 

using namespace std; 

int A; 
int B; 
int E; 
int C; 
int D; 
int F; 
int X; 
int Y; 

int main(int argc, char *argv[]) 
{ 
    cout << "Given Ax + By = E and Cx + Dy = F\n"; 
    cout << "\nA=?"; 
    cin >> A; 
    cout << "\nB=?"; 
    cin >> B; 
    cout << "\nE=?"; 
    cin >> E; 
    cout << "\nC=?"; 
    cin >> C; 
    cout << "\nD=?"; 
    cin >> D; 
    cout << "\nF=?"; 
    cin >> F; 
    
     X=((E*D-B*F)/(A*D-B*C)); 
     Y=((A*F-E*C)/(A*D-B*C)); 
     cout << "\n X=" << X; 
     cout << "\n Y=" << Y; 
     int DumbyVar;
     cin >> DumbyVar;	
     return 0; 
}   
 
 

Posted: Wed Dec 01, 2004 5:32 pm
by Falco Girgis
That's not an error nor a problem. You did that. What'd you think you were saying by this:

Code: Select all

int A;
int B;
int E;
int C;
int D;
int F;
int X;
int Y; 
You were declaring all of those variables as integers. An integer is a whole number. You'll need them as fractions. So declare them as float like so:

Code: Select all

float A;
float B;
float E;
float C;
float D;
float F;
float X;
float Y; 
Also, why not declare those variables like this:

Code: Select all

float A, B, E, C, D, F, X, Y
That's alot easier to read/deal with and more efficient.

Posted: Wed Dec 01, 2004 6:06 pm
by cobain
Okay, thanks alot. Now is there any way that I can turn those fractions into decimals automatically? Thanks for the float thing.

Posted: Wed Dec 01, 2004 7:02 pm
by Falco Girgis
Well, actually, they are represented as (floating) point decimals already. I don't know how to make it round to a certain place after the point, but I guess you could use the C method like this:

Code: Select all

printf("%.2f", some_variable);
The %f just means that you're printing a float, and the .2 means that's how many places passed the decimal. Then you have to have a comma + the variable.

Posted: Wed Dec 01, 2004 7:22 pm
by cobain
Sorry, I had a typo in my last post, I meant turn those decimals into fractions. Sorry man, but I wil use that decimal round thing sometime. Sorry about that, but how do you turn that decimal into a fraction automatically?

Posted: Thu Dec 02, 2004 7:32 am
by JS Lemming
I wouldn't suggest trying to make them look like fractions in a console box. Its just not worth it and it teaches you nothing. Just try to read more of your book so you can move on to bigger and better things.

Posted: Fri Dec 03, 2004 4:32 pm
by cobain
Hi. I have taken JS Lemmings advice and I continue to study / read my C++ book. The questions that follow are just out of curiosity as to the limitations of C++ and different C++ application types. Please, If the answer is long or complicated, just say no.
1) Is there any way to decompile a program written in C++ back into C++?
2) What types of applications are there besides console and windows? What is a "windows application" typically used for? And a console application?
3) Is it possible for a program to access another program to graph something or fill in specified pixels? Can a console app. access the internet if a URL is specified? (Keep in mind, I dont want to know how to do it, just if it can be done :D )
4) Is it possible to make a console application factor a number (ie. 52) or a trinomial (ie. 7x^2 + 5x - 7) ?
5) Lastly, I do actually need help w/ how to do this stuff, and my book requires that some of it be done. I need certain math symbols while programming (ie. a square root or cubed root). JS Lemming told me to put at the top

Code: Select all

#include <math.h>
, ok, thats done. Now I need commands for that math.h stuff, and I have searched google and numerous other websites for the actual commands that can be used once math.h is put in at the top, any suggestions on websites or books?
Also, how can you define different namespaces? Just replace the "std" with something else? Can two or more different namespaces be called upon during the same program? (I actually would do nothing with this information, I am just curious). And VERY lastly, is

Code: Select all

#include <math.h>
a different namespace from STD?
So sorry about the long post, I am just a curious little guy :D . But I really would like to know most of the different <math.h> commands please.

Posted: Fri Dec 03, 2004 5:03 pm
by Falco Girgis
cobain wrote:The questions that follow are just out of curiosity as to the limitations of C++[..]
There is no such thing as a limitation with C++. Name one thing that it can't do that doesn't direcly manipulate hardware (that's assembly). There are things that you aren't allowed to do, and there are ways in which you must do things, but anything is possible there are no limits.
cobain wrote:1) Is there any way to decompile a program written in C++ back into C++?
Yes and no. Yes there are a couple of "would-be decompilers out there". They are all garbage and don't even work in the least. You don't realize how complicated it'd be to make one. Also, it's good that they don't. Would you like for all of your work and stuff to be easily stolen by decompilation? I think it's garbage myself.
cobain wrote:2) What types of applications are there besides console and windows? What is a "windows application" typically used for? And a console application?
Windows application is like NEStix Chaotix, Doom 3, Half-Life 2, games/applications for windows. Console application is like what you're doing. Black boxage.

What types of applications besides them? Maybe you should ask the reverse. Dude, I program DREAMCAST, Sega's 128-bit console with C++. There is really an infinate amount of applications with C++.
cobain wrote:3) Is it possible for a program to access another program to graph something or fill in specified pixels? Can a console app. access the internet if a URL is specified? (Keep in mind, I dont want to know how to do it, just if it can be done Very Happy )
Access another program to graph or fill in specified pixels. Umm... yeah, it's possible, but I really don't see any point there. What'd that be for?

Console app accessing the internet? Of course! You'd need to learn about sockets and stuff though.

cobain wrote:4) Is it possible to make a console application factor a number (ie. 52) or a trinomial (ie. 7x^2 + 5x - 7) ?
OF COURSE THAT'S POSSIBLE! Man, the console is offended. That's nothing. Trinomial is still possible, but it'd be a pain in the ass to make.
cobain wrote:5) Lastly, I do actually need help w/ how to do this stuff, and my book requires that some of it be done. I need certain math symbols while programming (ie. a square root or cubed root). JS Lemming told me to put at the top
This is C++ so you might wanna do this instead.

Code: Select all

#include <cmath>
What JSL showed you is C-style.

If you really want to see what is in cmath/math.h, why don't you just open it up in your Dev environment?

Really quick, you'd do this for powers:

Code: Select all

pow(variable/number, power you want it raised to);
for example I could say:

Code: Select all

pow(2, 2);
That squares 2 making it 4.

Here is a nice site to give you the low-down of math.h: http://www.cplusplus.com/ref/cmath/
cobain wrote: Also, how can you define different namespaces? Just replace the "std" with something else?
yep.
cobain wrote:Can two or more different namespaces be called upon during the same program? (I actually would do nothing with this information, I am just curious).
No, a namespace tells the compiler where all of the functions are. You can't say that all of the functions are from 2 libraries (I don't think). There is an alternative, I can show you later, but I don't wanna overload you now.
cobain wrote:And VERY lastly, is

Code: Select all

#include <math.h>
a different namespace from STD?
Okay, this part might get complicated. No, it is not. math.h is just a group of functions. They aren't in a class/struct so they're global meaning that they can be accessed anywhere in the program without specifying where they are from.

Cin and Cout are in a class. That means that you must call/reference theme through the class. When you say that you're using namespace std;, you're saying to make all of the functions in the class globals so that they can be accessed anywhere without having to specify the class they are from.
cobain wrote:I am just a curious little guy Very Happy :D
yeah, that's cool. I've never heard anybody ask that namespace question. I'm sure you won't understand that explanation fully (I sure wouldn't of), but don't worry, no biggie. If you have any more questions, just post. :D