![]() |
Beginner begging: problems with Builder!
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! |
Re: Beginner begging: problems with Builder!
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/ex...d/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. |
Re: Beginner begging: problems with Builder!
* 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? |
Re: Beginner begging: problems with Builder!
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! |
Re: Beginner begging: problems with Builder!
Alf P. Steinbach <alfps@start.no> 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. |
Re: Beginner begging: problems with Builder!
Christopher Benson-Manica wrote:
> Alf P. Steinbach <alfps@start.no> 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. |
Re: Beginner begging: problems with Builder!
Christopher Benson-Manica <ataru@otaku.freeshell.org> wrote:
> Alf P. Steinbach <alfps@start.no> 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+...C_and_all_that... -- Marcus Kwok Replace 'invalid' with 'net' to reply |
| All times are GMT. The time now is 08:59 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.