Newbie question about VS in general...

OK, I got a version of VS... but im having real troubles getting anything done in this... I mean I know how to write "hello world" for example but err how to compile for one and what kind of a file/project do I choose... they all just give me these big source codes from the start but what if I want to do something all my own (hello world for example )... someone answer me quick...



Answer this question

Newbie question about VS in general...

  • Dukebaby

    wow thanks!! :D thats pretty much all I needed... and yes, I looked this up from a tutorial (which they said was outdated, but I thought wasnt that important...stupid me) so now I found a new website to look from... and I think I can continue! now THANKS! :D
    IM SOOOOOOOO HAPPY!!!! *waves*


  • Shoaib Aleem

    helloworld - 2 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    The build log says you've got 2 errors in your program. In order to create a program, you MUST have 0 errors (and although not required, you should also have 0 warnings). So what are the 2 problems with your program

    #include <iostream.h>

    void main()
    {
    cout << "Hello world!";
    }

    Where did you get this code from Was it from a book If so, it seems to be outdated. Although this used to be correct code (before 1998), it no longer is correct C++ code (since C++ became standard).

    1. It's #include <iostream>, NOT #include <iostream.h> (notice, no .h in the end).
    2. You cannot use cout until you pull in the std namespace. You either need to add using namespace std (or using std::cout), or prefix cout with std::.

    Here is a corrected version of this code:

    #include <iostream>

    int main()
    {

    using namespace std;
    cout << "Hello World";
    return 0;

    }

    I suggest you read Ayman's blog post on the topic.

    PS. If you're learning C++ from a book, I suggest you find a later edition of that book, one which was written to deal with standardised C++.



  • E. Richards

    YIkes...

    #include <iostream>

    int main()

    {

      using namespace std;
      cout << "Hello World";
      return 0;

    }


    that is my new code....and it still gives 1 error :F

    it says that cout is an unidentified identifier now I dont get what that means but at least now I only got 1 error... Im hopeless :G

    edit...: here is the error :

    ------ Build started: Project: hello world, Configuration: Debug Win32 ------
    Compiling...
    kokeilu.cpp
    c:\documents and settings\toni\my documents\visual studio 2005\projects\kokeilu\kokeilu.cpp(6) : error C2065: 'cout' : undeclared identifier
    Build log was saved at "file://c:\Documents and Settings\Toni\My Documents\Visual Studio 2005\Projects\Debug\BuildLog.htm"
    uusi hello world - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



  • Seabhcan

    If you wrote that cpp file from something other than Visual Studio, you'll need to use the File -> New -> New Project From Existing Code wizard. Follow the wizard. Browse to your cpp file, give your program a name, and when asked for the project type, choose a console application. Ignore the last two pages in the wizard, and press finish.

    Now you can click the green start button in the toolbar to build/debug your application



  • rick1234

    It looks like your project consists of two files:

    1. helloworld.cpp (I know what this file is)
    2. kokeilu.cpp . What is this  What is the content of this file

    If kokeilu.cpp is not supposed to be part of your project, remove it from your project (using the Solution Explorer tab).



  • Shane Colin

    here is my next problem...

    #include <iostream.h>

    void main()
    {
    cout << "Hello world!";
    }
    that up there is my code...now that I press the play button (debug/compile)... it gives me an error saying this :

    "unable to start program 'c:/documents and settings/toni/my documents/visual studio 2005/projects/debug/helloworld.exe'.

    the system cannot find the file specified."

    and before this I made a .cpp file in VS2005... saved it, then did what you said to do... after this I press the green button (as I already said...) and it says that it compiles... does all kinds of stuf... then I get that popup :( dunno really what to do

    ------ Build started: Project: helloworld, Configuration: Debug Win32 ------
    Compiling...
    helloworld.cpp
    c:\documents and settings\toni\my documents\visual studio 2005\projects\helloworld.cpp(1) : fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory
    kokeilu.cpp
    c:\documents and settings\toni\my documents\visual studio 2005\projects\kokeilu\kokeilu.cpp(6) : error C2065: 'cout' : undeclared identifier
    Generating Code...
    Build log was saved at "file://c:\Documents and Settings\Toni\My Documents\Visual Studio 2005\Projects\Debug\BuildLog.htm"
    helloworld - 2 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


  • Newbie question about VS in general...