Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [Example / Listing] I felt the need to program something.. and... well..  (Read 2973 times)

0 Members and 1 Guest are viewing this topic.
[Example / Listing] I felt the need to program s...
« on: May 09, 2006, 09:16:08 pm »
  • You don't know me.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 234
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. >.>
« Last Edit: February 24, 2012, 06:17:43 pm by Niek »
Logged


No one located in this area of the internet remembers me.

Goodnight

Once and future Captain
Re: I felt the need to program something.. and.....
« Reply #1 on: May 09, 2006, 10:04:26 pm »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
I think you just wrote the long-awaited sequel to Hello World. :o Good job!
Logged
Re: I felt the need to program something.. and.....
« Reply #2 on: May 09, 2006, 10:23:20 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
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; }
Logged
Re: I felt the need to program something.. and.....
« Reply #3 on: May 09, 2006, 10:46:00 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1141
This is so funny! ;D
Logged
Re: I felt the need to program something.. and.....
« Reply #4 on: May 09, 2006, 11:06:40 pm »
  • You don't know me.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 234
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
Logged


No one located in this area of the internet remembers me.
Re: I felt the need to program something.. and.....
« Reply #5 on: May 10, 2006, 12:05:56 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 4588
Code: [Select]
using namespace std; int main(int argc, char *argv[])I was about to post the same thing XD
Logged
the a o d c
Re: I felt the need to program something.. and.....
« Reply #6 on: May 10, 2006, 10:43:33 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
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.
Logged
Re: I felt the need to program something.. and.....
« Reply #7 on: May 10, 2006, 09:11:19 pm »
  • The Broken King
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1259
the arguments are for windows-based console applications, for the most part yuo don't actually need them.
Logged
  • Broken Kings [Temp Site]
Re: I felt the need to program something.. and.....
« Reply #8 on: May 10, 2006, 10:51:18 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 221
XD Nice program!  ;) I'll have to remember that cin.get() thing.
Logged
Pages: [1]   Go Up

 


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



Page created in 0.165 seconds with 55 queries.