n00b: trying to compile 'hello world' in visual studio 2010
Register

We are the best invite forum on the internet! Here you will find free invites, free seedboxes, free bonuses, and much more. Our members know the true meaning of sharing and have created a truly global bittorent community! Our site has the most up to date information on all private trackers and our members will guide you and introduce you to this truly secretive and enlightened club. Ready to get started? Register now!


Results 1 to 9 of 9
  1. #1

    Join Date
    Nov 2010
    Location
    Texas
    Posts
    414

    Default n00b: trying to compile 'hello world' in visual studio 2010

    im trying to compile the basic 'hello world' in vs2010 and the build icons are greyed out. any reason why?

    #include <iostream.h>

    int main ()
    {
    cout << "Hello World!\n";
    return 0;
    }


    ::edit::

    vs can't seem to find 'iostream.h' file.

    ::edit::

    nevermind the iostream.h. apparently its iostream now. but i still can't build the damn thing. /cry

    Last edited by nivlac; April 24th, 2011 at 09:05 AM.


  2. To remove ads become VIP. Inquire about advertising here.
  3. #2

    Join Date
    Dec 2009
    Location
    Switzerland
    Posts
    445

    Default Re: n00b: trying to compile 'hello world' in visual studio 2010

    You can't compile because the icon is greyed out? I could only imagine two situations this happens:

    - a build is currently running, which is propably not
    - maybe a stupid question: Did you create a project? You can open a cpp file with VS, but you won't be able to compile it, so you need to create a project and include your files in the project


    Edit: I'm not sure if I understood your question. But just detected a mistake. Try this:

    #include <iostream.h>

    using namespace std;

    int main ()
    {
    cout << "Hello World!\n";
    return 0;
    }
    Last edited by Tim; April 24th, 2011 at 10:18 PM.

  4. #3

    Join Date
    Oct 2010
    Posts
    26

    Default Re: n00b: trying to compile 'hello world' in visual studio 2010

    I suspect the same as Tim . Did you make a C++ project or are you just trying to compile standalone C++ file.

    If you have not made a project go to File-->New project -->Visual c++ -->empty project.
    Add your .cpp in the project . Now Build should not be greyed out.

  5. #4

    Join Date
    Apr 2011
    Posts
    13

    Default Re: n00b: trying to compile 'hello world' in visual studio 2010

    Not sure about the whole project thing, but I created a file "hello.cpp" like this:

    #include <iostream>

    using namespace std;

    int main ()
    {
    cout << "Hello World!\n";
    return 0;
    }

    compiled it and ran it. Does cout even work in visual studio? Isnt that command line specific? To be honest, I've only used vs a few times.

  6. #5

    Join Date
    Mar 2011
    Posts
    75

    Default Re: n00b: trying to compile 'hello world' in visual studio 2010

    Quote Originally Posted by nivlac View Post
    nevermind the iostream.h. apparently its iostream now. but i still can't build the damn thing. /cry
    You will encounter situations like these a fair bit in your programming life :) So your first problem was that the compiler couldn't find the header file, because you don't write ".h" for that particular include. You solved that problem yourself, so if it's still not building there must be another error, otherwise you will get "0 errors 0 warnings" in the console window. What is that error?

  7. #6

    Join Date
    Oct 2010
    Posts
    26

    Default Re: n00b: trying to compile 'hello world' in visual studio 2010

    Quote Originally Posted by agent69 View Post
    Not sure about the whole project thing, but I created a file "hello.cpp" like this:

    Does cout even work in visual studio? Isnt that command line specific?
    It surely does. You can also make console applications on Visual Studio , not just GUI based

  8. #7

    Join Date
    May 2011
    Posts
    32

    Default Re: n00b: trying to compile 'hello world' in visual studio 2010

    please follow this step creating project,

    file->new->project
    win32->win32 console application
    wizard->press next
    choose [Console application] & Empty Project!!!

    After thses steps you will have an empty c++ console project.

    Add your cpp file to project and it will compile.

  9. #8

    Join Date
    Dec 2010
    Location
    Bulgaria
    Posts
    1,356

    Default Re: n00b: trying to compile 'hello world' in visual studio 2010

    Your code should work in CodeBlocks or DevCpp ( you will need also system("pause") ) , for VS you probably should follow ebirlik's tip.
    Last edited by PROMOTER; June 18th, 2011 at 02:42 AM.
    Need to promote something ? Ask the star.pngPROMOTER !

  10. #9

    Join Date
    Mar 2011
    Posts
    44

    Default Re: n00b: trying to compile 'hello world' in visual studio 2010

    It's worth noting that as currently written, even if this program compiles, when you run it you won't see the output. In Visual Studio, when you run a console application, it automatically gets closed after it finishes executing. To actually see the "Hello World" outputted, you should add

    Code:
    system("pause");
    to the bottom of your program (just before the "return 0;" line). This is the most common work-around people use, but it's kind of ugly and you shouldn't get in the habit of doing it because it makes your programs not work on other operating systems. You should look at this thread at Microsoft for more information, and for a better work-around (see the last post).

    Hope this helps.

Similar Threads

  1. Replies: 11
    Last Post: May 30th, 2010, 08:00 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •