Beginner begging: problems with Builder!

J

JohnS

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!
 
S

sdavids

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.
 
A

Alf P. Steinbach

* 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;
}
 
S

sdavids

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!
 
C

Christopher Benson-Manica

Alf P. Steinbach said:
#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?
 
R

red floyd

Christopher said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top