Beginner begging: problems with Builder!

Discussion in 'C++' started by JohnS, Jun 9, 2006.

  1. JohnS

    JohnS Guest

    I am learning how to use C++ -- I'm using the Borland C++ Builder.

    I tried to do the first little "Hello World!" programs in the book.
    What is supposed to happen is I type in the code like it shows in the
    book, and a DOS window is supposed to pop up when it is done compiling.
    What actually happens is . . . nothing. The little window pops up that
    says it is compling, and then nothing happens. No DOS window. The title
    bar of the window says it is running, but it never stops. I can pause
    it, and reset the program, but every time I tell it to run, nothing
    happens. I've tried reinstalling the program. I once got an error
    message about the BDE, but I didn't see any change. When I close the
    program, it says it is in the middle of debugging, which I didn't tell
    it to do.

    Any insight will be greatly appreciated by this programming noob.

    Thanks!
     
    JohnS, Jun 9, 2006
    #1
    1. Advertising

  2. JohnS

    sdavids Guest

    Well your program should pretty much just be:

    #include <iostream>

    int main()
    {
    cout << "Hello World" << endl;
    return 0;
    }

    and it should be thrown into main.cpp - - Now if you have exactly that
    it might be whatever program you are using to compile the code, what
    are you using? I would suggest going with Microsoft Visual C++ 2005
    Express - - it has everything you need as a beginner you can download
    it here:
    http://msdn.microsoft.com/vstudio/express/visualc/download/default.aspx
    If you download that you are going to want to make a new win32 console
    based project, compeletly blank, then you can just add your single
    main.cpp file in there with your code and compile it.
     
    sdavids, Jun 9, 2006
    #2
    1. Advertising

  3. * sdavids:
    > Well your program should pretty much just be:
    >
    > #include <iostream>
    >
    > int main()
    > {
    > cout << "Hello World" << endl;
    > return 0;
    > }


    That shouldn't compile.

    This is a formally valid hello world in C++:

    #include <iostream>
    #include <ostream>
    int main()
    {
    std::cout << "Hello, world!" << std::endl;
    }

    The following is an in-practice valid hello world in C++:

    #include <iostream>
    int main()
    {
    using namespace std;
    cout << "Hello, world!" << endl;
    }

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Jun 9, 2006
    #3
  4. JohnS

    sdavids Guest

    True, I forgot the "using namespace std;" which I usually throw up
    right below my #includes. Although you might want to check out Java,
    since it seems to be less complicated than C++ since in Java its not as
    confusing to manipulate data, like passing by reference and using
    pointers and such, plus Java does copy constructors and deconstructors
    for you. Since Java does all these things for you it is a slower
    programming language than C++ but from what I see a lot of companies
    decide to go with Java because of the ease, although some companies
    that demand performance like Microsoft strictly use C++. If you want to
    play around with Java you can get plenty of tutorials online and you
    can get your compiler at www.eclipse.org - IBM makes it, and its pretty
    much the Visual Studio equivalent for Java. If you are interested in
    the similarities between Java and C++ they are all pretty similar, here
    is an example hello world program:

    public class Hello {
    public static void main(String []args)
    {
    System.out.println("Hello World!");
    }
    }

    Dont let the class intimidate you, read about 2 chapters in front of
    the Hello World program in your book to read about it. Its nice in Java
    how you dont need seperate .h and .cpp files to declare / implement all
    your code. Have fun!
     
    sdavids, Jun 9, 2006
    #4
  5. Alf P. Steinbach <> wrote:

    > #include <iostream>
    > #include <ostream>
    > int main()
    > {
    > std::cout << "Hello, world!" << std::endl;
    > }


    All right, I admit I don't know why both <iostream> and <ostream> are
    needed here. Care to elaborate?

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
     
    Christopher Benson-Manica, Jun 9, 2006
    #5
  6. JohnS

    red floyd Guest

    Christopher Benson-Manica wrote:
    > Alf P. Steinbach <> wrote:
    >
    >> #include <iostream>
    >> #include <ostream>
    >> int main()
    >> {
    >> std::cout << "Hello, world!" << std::endl;
    >> }

    >
    > All right, I admit I don't know why both <iostream> and <ostream> are
    > needed here. Care to elaborate?
    >


    I believe endl is technically only in ostream.
     
    red floyd, Jun 9, 2006
    #6
  7. JohnS

    Marcus Kwok Guest

    Christopher Benson-Manica <> wrote:
    > Alf P. Steinbach <> wrote:
    >
    >> #include <iostream>
    >> #include <ostream>
    >> int main()
    >> {
    >> std::cout << "Hello, world!" << std::endl;
    >> }

    >
    > All right, I admit I don't know why both <iostream> and <ostream> are
    > needed here. Care to elaborate?


    <ostream> is needed for std::endl, however, in practice most
    implementations I know of (with the exception of aCC on HP-UX) will let
    you get away with just <iostream>.

    There is somewhat of a discussion at
    http://en.wikipedia.org/wiki/Talk:C...E.2C_.23include_.3Cistream.3E.2C_and_all_that...

    --
    Marcus Kwok
    Replace 'invalid' with 'net' to reply
     
    Marcus Kwok, Jun 9, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Micah
    Replies:
    11
    Views:
    478
    DogWalker
    Apr 27, 2006
  2. The Eternal Squire

    Open letter to BDFL begging forgiveness.

    The Eternal Squire, Aug 6, 2006, in forum: Python
    Replies:
    3
    Views:
    310
    Alex Martelli
    Aug 7, 2006
  3. Replies:
    2
    Views:
    341
    osmium
    Dec 10, 2006
  4. nav

    For Begging with java

    nav, May 1, 2007, in forum: Java
    Replies:
    2
    Views:
    337
    pundeerd
    May 2, 2007
  5. Benny
    Replies:
    6
    Views:
    93
    Thomas Fini Hansen
    May 22, 2004
Loading...

Share This Page