ZFGC

Resources => Coding => Topic started by: Hero of Vortex on May 09, 2006, 09:16:08 pm

Title: [Example / Listing] I felt the need to program something.. and... well..
Post by: Hero of Vortex on May 09, 2006, 09:16:08 pm
Code: [Select]
// I had an urge to program something...
// I know, I'm crazy.

#include <iostream>

using std::cout; // These were either made for the lazy or to save space.
using std::cin;

// I don't think I'll need any functions.

int main() // Start main program.
{
   
    int YourNumber;  // The variable that I'll use.
                     // Not that it changes anything. :D
   
    cout << "Hello there.\n"; // Says a greeting.
   
    cin.get(); // Some wierd thing I see on the internet a lot that
               // is supposedly better than system pause but does the same thing. =\
   
    cout << "I would very much like to \nknow your favorite number.\n"; // The indication of what to enter.
   
    cin >> YourNumber; // This is how we input our variables. Input our variables,
                       // input our variables...
   
    cout << "WTF? Your favorite number is "; // Insult. Note how putting
    cout << YourNumber; // the variable there makes it show the number.
    cout << "?! \n";  // Just putting this here to show that it is part of the insult.
                                                                 
   
    cin.get(); // That wierd thingy again...
   
    cout << "You're strange.\n";  // Last message and insult. :D
   
    cin.get(); // THat thing one more time.
   
    return 0;  // Signal the compiler that everything was succesful.
   
} // The end of the main program! Though calling it "main" is kind of innacurate when
  // there aren't any functions.


And you can see that when I say random, I MEAN random. >.>
Title: Re: I felt the need to program something.. and... well..
Post by: Goodnight on May 09, 2006, 10:04:26 pm
I think you just wrote the long-awaited sequel to Hello World. :o Good job!
Title: Re: I felt the need to program something.. and... well..
Post by: Infinitus on May 09, 2006, 10:23:20 pm
And just because im absolutly bored, i optimized it abit, and stuck it all in 2 lines XD

Code: [Select]
#include <iostream>
using namespace std; int main(int argc, char *argv[]) { int iNumber; cout << "Hello there.\nI would very much like to know your favorite number.\n>"; cin  >> iNumber; cout << "WTF? Your favorite number is " << iNumber << "?!\nYou're strange.\n"; cin.get(); return EXIT_SUCCESS; }
Title: Re: I felt the need to program something.. and... well..
Post by: sjegtp on May 09, 2006, 10:46:00 pm
This is so funny! ;D
Title: Re: I felt the need to program something.. and... well..
Post by: Hero of Vortex on May 09, 2006, 11:06:40 pm
This is so funny! ;D

Unfortanutely, since this is the internet, I can't tell if you mean that or if you're being sarcastic. >.> So I'll assume you mean it! >.> Thanks.

I think you just wrote the long-awaited sequel to Hello World. :o Good job!

People wanted a sequel to Hello World?


And just because im absolutly bored, i optimized it abit, and stuck it all in 2 lines XD

Code: [Select]
#include <iostream>
using namespace std; int main(int argc, char *argv[]) { int iNumber; cout << "Hello there.\nI would very much like to know your favorite number.\n>"; cin  >> iNumber; cout << "WTF? Your favorite number is " << iNumber << "?!\nYou're strange.\n"; cin.get(); return EXIT_SUCCESS; }


That has things in there that I've never even heard of! O_O
Title: Re: I felt the need to program something.. and... well..
Post by: AoDC on May 10, 2006, 12:05:56 am
Code: [Select]
using namespace std; int main(int argc, char *argv[])I was about to post the same thing XD
Title: Re: I felt the need to program something.. and... well..
Post by: Infinitus on May 10, 2006, 10:43:33 am
Code: [Select]
using namespace std; int main(int argc, char *argv[])I was about to post the same thing XD

Quite simple really, "using namespace std" just imports the std namespace so you can use its symbols(Functions, variables...what not).

The argc parameter is equal to the number of command-line parameters passed to this program.

The argv parameter is an array of the command-line parameters passed to this program.
Title: Re: I felt the need to program something.. and... well..
Post by: therabidwombat on May 10, 2006, 09:11:19 pm
the arguments are for windows-based console applications, for the most part yuo don't actually need them.
Title: Re: I felt the need to program something.. and... well..
Post by: Soulja on May 10, 2006, 10:51:18 pm
XD Nice program!  ;) I'll have to remember that cin.get() thing.

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved