HELP PLEASE

I AM BUILDING A SIMPLE PROGRAM BUT I GET A PROBLEM THIS IS THE CODE

 

#include <iostream>

main()

(

std::cout << "Hello World!" << std::endl;

)

When i press buil solution it show me this message

1>------ Build started: Project: hello, Configuration: Debug Win32 ------

1>Compiling...

1>hugo.cpp

1>c:\documents and settings\hpolanco\my documents\visual studio 2005\projects\hello\hello\hugo.cpp(5) : error C2143: syntax error : missing ')' before ';'

1>c:\documents and settings\hpolanco\my documents\visual studio 2005\projects\hello\hello\hugo.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>c:\documents and settings\hpolanco\my documents\visual studio 2005\projects\hello\hello\hugo.cpp(5) : error C2072: 'main' : initialization of a function

1>c:\documents and settings\hpolanco\my documents\visual studio 2005\projects\hello\hello\hugo.cpp(6) : error C2059: syntax error : ')'

1>Build log was saved at "file://c:\Documents and Settings\hpolanco\My Documents\Visual Studio 2005\Projects\hello\hello\Debug\BuildLog.htm"

1>hello - 4 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped there is a problem

i am noob with this but i just want to lear somo programming stuff i got another problem where can i download a stk for windows xp pro media center 2005 or i have to intall windows server 2003

my machines is a p4 3.0ghz with a intel board 865 pearl

please give a hand with this



Answer this question

HELP PLEASE

  • Hybidder

    This is basic.. keep basics strong:

    u should use instead of , there are hell a lot of difference between this,

    main()
    {
    std::cout << "Hello World!" << std::endl;
    }

    this should work !!



  • neosamz

    you need to declare the type of main() now days:

    #include <iostream>

    int main()

    {

    std::cout << "Hello World!" << std::endl;

    return 0;

    }

    you could have done this:

    #include <iostream>

    void main()

    {

    std::cout << "Hello World!" << std::endl;

    }

    I'm not really sure what the purists think. But I would have done it like this:

    #include <iostream>

    using namespace std;

    int main()

    {

    cout << "Hello World!" << endl;

    return 0;

    }

     


  • hokial

     Takashi Toyota wrote:
    Hi,
    I recommend this;

    int main()
    {    std::cout << "Hello World!" << std::endl;}

    Yes u can but u will get a warning :

    warning C4508: 'main' : function should return a value; 'void' return type assumed
    Linking...

    so nothing wrong in doing  this:

    main()
    {     std::cout << "Hello World!" << std::endl;}

    if ur still going to use int then go a head but add this return(0);

    Takashi Toyota : do u find anything wrong in my code   :)   :)   :)



  • martind2112

     Takashi Toyota wrote:
    Hi,
    return 0; // Sorry. I forgot this!
    }I almost follow his advice.
    Nothing wrong dude... but nothing lost.You are doing a good job. 
    keep rocking.
     


  • AmandaJO

     brenthellbent wrote:

    you need to declare the type of main() now days:

    Not exactly !!



  • Clement Yuan

    Hi,


    The following code is taken from Dr.Bjarne Stroustrup Web site.
    My real intention is this;

    #include<iostream>
    #include<string>
    using namespace std;
    int main()
    {
    string s;
    cout << "Please enter your first name followed by a newline\n";
    cin >> s;
    cout << "Hello, " << s << '\n';
    return 0; // Sorry. I forgot this!
    }
    I almost follow his advice.



  • jecottrell65

    Hi,

    I recommend this;

    int main()
    {
          std::cout << "Hello World!" << std::endl;
    }



  • HELP PLEASE