Thread: Noob - Hello World Not Working

  1. #16
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    477
    Quote Originally Posted by abachler View Post
    portable solution that works with every IDE

    Code:
    #include <iostream>
    #include <conio>
    using namespace std;
    
    int main (){
        cout << "Hello World!\n";
        cout << "Press any key to continue..."  
        getch();
        return 0;
        }
    How are you justifying a) including a whole separate header file for a single function and b) doing that for a function that has an equivalent defined in istream and all its derivatives(cin) and c) calling that portable?

    cin.get() does the trick for you, really.
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  2. #17
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by IceDane View Post
    How are you justifying a) including a whole separate header file for a single function and b) doing that for a function that has an equivalent defined in istream and all its derivatives(cin) and c) calling that portable?

    cin.get() does the trick for you, really.

    because its hello world, not 'This has to pass a code review'.

  3. #18
    Registered User
    Join Date
    Sep 2009
    Posts
    12
    Quote Originally Posted by StainedBlue View Post
    ^never a good idea.
    Forgive me for being uninformed, but just why is it a bad idea?

    Dev-C++ automatically inserts
    Code:
      system("PAUSE");
        return EXIT_SUCCESS;
    -at the end of a source file if you choose to make a new console-based project. Does it make the code inefficient or something?

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It is non-portable. Only works in Windows, and it is vulnerable to certain attacks, I believe. Plus it has overhead.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #20
    Registered User
    Join Date
    Aug 2006
    Posts
    6
    Quote Originally Posted by Angie View Post
    Forgive me for being uninformed, but just why is it a bad idea?
    Things to Avoid in C/C++ -- system("pause")

    Also, Dev-C++ hasn't been updated in ~4 years. Try wxDev-C++, Code::Blocks, or Visual C++ Express 2008.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Too much to ask ?
    By deflamol in forum C Programming
    Replies: 2
    Last Post: 05-06-2004, 04:30 PM
  2. Hello World 180 KB???????
    By Musicdip in forum C++ Programming
    Replies: 17
    Last Post: 06-22-2002, 07:27 PM
  3. Who should rule the world?
    By CoderBob in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 02-07-2002, 07:01 AM
  4. Religious Bull****
    By Witch_King in forum A Brief History of Cprogramming.com
    Replies: 119
    Last Post: 10-23-2001, 07:14 AM
  5. No More Technology After World War Three
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-20-2001, 07:02 PM