| |
Giygas learns the art of C++
Xgoff |
|

<):|
![Super Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/shappyheart.gif) ![Sprite Comp Winner Badge (1) [*]](https://archive.mfgg.net/html/badges/scg1.gif) ![Drawing Comp Winner Badge (1) [*]](https://archive.mfgg.net/html/badges/dcg1.gif) ![Drawing Comp Runner Up Badge (1) [*]](https://archive.mfgg.net/html/badges/dcr1.gif) ![MFGG Awards 2006 Winner [*]](https://archive.mfgg.net/html/badges/award06.gif)
![MFGG Awards 2007 Winner [*]](https://archive.mfgg.net/html/badges/award07.gif) ![Forum Event Badge [*]](https://archive.mfgg.net/html/badges/event.gif)

Group: Members
Posts: 52341
Member No.: 24
Joined: 13-October 03
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
| QUOTE (ChaosEmerl @ Sep 24 2009, 12:52 PM) | That's technically not a function.
Or maybe C++ is just weird, I don't know. But in most languages, a function returns a value without you having to declare a variable for it. |
p sure that declaration is redundant anyway
EDIT: nvm i see what he did
that's kind of a weird way to write most functions
generally what you'd do is something like:
#include
using namespace std;
int divide(int a, int b)
{
return a/b;
}
int main ()
{
int u = divide(10,2);
cout << u;
system("pause");
return 0;
}
This post has been edited by Xgoff on Sep 24 2009, 02:00 PM
--------------------
 DISCLAIMER: by sending me (xgoff) a private message, you agree to the directives and their terms specified henceforth: DIRECTIVE 1 (APPLE): i may or may not reply promptly or at all; and there are no guarantees to the usefulness of the reply. i may not acknowledge whether i have even received your private message DIRECTIVE 2 (CHILE CON CARNE): as per my view, "private" applies only to the initial transaction, and the material of your message may or may not be made public at my discretion; as this will more than likely be a post in the CCC or IRC, you may not be able to view it DIRECTIVE 3 (FEATHER DUSTER): you must address me (xgoff) as "Sir Master Xgofficus his Highest and Most Awesome the Third"; failure to comply with this term may invoke one or both of the above directives, and i will leave a burning bag of **** on your doorstep DIRECTIVE 4 (BOOTSTRAP): if you have read this disclaimer, please private message me promptly, in compliance with the above terms, so i can ensure you are capable of following directions you idiot this concludes the test of the emergency disclaimer system, your scheduled programming will now continue. satisfaction guaranteed, and 100% cash back available under certain circumstances; restrictions may or may not apply within your place of residence NOTICE: these directives and their terms may change at any time, without notice; as a private message transaction to myself assumes an understanding and full compliance of the above, you should ensure you are fully aware of the above terms at any point before sending a private message; any message received is assumed to have been sent in compliance with the above| QUOTE | (5:25:58 PM) Mikau: xgoff (5:26:00 PM) Mikau: guess what (5:26:04 PM) Xgoff: chicken butt (5:26:09 PM) Mikau: **** you |
|
|
|
Giygas |
|

Standard Member
![Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/happyheart.gif)

Group: Members
Posts: 910
Member No.: 4767
Joined: 24-November 07
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
| QUOTE (RetroXYZ @ Sep 24 2009, 02:36 PM) | I don't get why people think C++ is hard. It's an extremely easy language (or at least, in my opinion) to learn, however, the sheer simplicity is what makes it difficult to apply to making programs.
With your program, you multiply the answer by x/RAND_MAX, x being the max number. In which case it would be 1 to x. |
Ah, awesome- that worked. After messing around, though, a quicker way is to do (rand() % x)+1 With x being max number, and the +1 making it so it can't be 0.
So the final code is:
| QUOTE | [size=0.1] #include<iostream> #include<string> using namespace std;
int main () { int myguess=242; int n = (rand() % 10) + 1; int t=3; while (myguess != n) { cout << "Try again! "; if (myguess > n) cout << "Go lower! "; else if (myguess < n) cout << "Go higher! "; cin >> myguess; t--; if (t==0) if (myguess != n) { cout << " Game over! "; system("pause"); return 0; } } if (myguess=n){ cout << "Correct!"; system("pause"); return 0; } }
|
3 triesto guess the number between 1 and 10. Yay :3
|
|
|
Lightning |
|

Ignorance isn't stupidity but choosing to remain ignorant is
![Super Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/shappyheart.gif) ![MFGG Awards 2008 Winner [*]](https://archive.mfgg.net/html/badges/award08.gif)

Group: IRC Operators
Posts: 6381
Member No.: 583
Joined: 31-August 04
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
you'd do well to stay at the console for now--learn how to deal with arrays, STL vectors and strings, and classes first, before you move on to graphics.
--------------------
click here to change my avatar. / gosh why are you even here lightninghacker, n.an individual who enjoys learning computer system details and how to capitalize on his or her capabilities...not a criminal. (from webster's new world hacker dictionary) |  Fedora 10 Final! Download today! | quality web comics (stories):- girl genius: adventure! romance! mad science!
- punch an' pie: try a slice of life, then swallow.
- dresden codak: most interesting comic ever
quality web comics (one-shots):- a softer world: truth and beauty bombs
- smbc: saturday morning breakfast cereal
- buttersafe: pictures and probably some words
|
"Religion is comparable to a childhood neurosis." - Sigmund Freud “It is not by delusion, however exalted, that mankind can prosper, but only by unswerving courage in the pursuit of truth.” - Bertrand Russell “To kill an error is as good a service as, and sometimes better than, the establishing of a new truth or fact.” - Charles Darwin
|
|
|
OniLink10 |
|

C++ Programmer, Unofficial Physicist, and Unofficial Chemist
![Super Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/shappyheart.gif) ![Secret Santa Badge [*]](https://archive.mfgg.net/html/badges/present.gif)

Group: Members
Posts: 3920
Member No.: 4907
Joined: 19-February 08
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
Once you have figured out all of the Console Commands and basics, I would highly recommend getting SFML and using that for Graphics, Windowing, Input, Multithreading(le gasp! It's complicated, but if you can figure it out, you can use it for turning one program into two and taking full use of multi-core Processors), Audio, Networking, etc. It's a great library, and uses OpenGL for High-speed Rendering and Pixel Shaders! Of course, you should finish learning the basics first, and stick with that until you get used to everything.
--------------------
| QUOTE (Xgoff @ Sep 10 2009 @ 06:11 PM) | did you try hello's engine
make sure to not ****ing change anything before using it! |
|
|
|
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
[ Script Execution time: 0.1019 ] [ 13 queries used ] [ GZIP Enabled ] [ Server Load: 1.52 ]
| |