Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Beginner begging: problems with Builder!

Reply
Thread Tools

Beginner begging: problems with Builder!

 
 
JohnS
Guest
Posts: n/a
 
      06-09-2006
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!

 
Reply With Quote
 
 
 
 
sdavids
Guest
Posts: n/a
 
      06-09-2006
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.

 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      06-09-2006
* 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?
 
Reply With Quote
 
sdavids
Guest
Posts: n/a
 
      06-09-2006
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!

 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      06-09-2006
Alf P. Steinbach <(E-Mail Removed)> 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.
 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      06-09-2006
Christopher Benson-Manica wrote:
> Alf P. Steinbach <(E-Mail Removed)> 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.
 
Reply With Quote
 
Marcus Kwok
Guest
Posts: n/a
 
      06-09-2006
Christopher Benson-Manica <(E-Mail Removed)> wrote:
> Alf P. Steinbach <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginner's Beginner william nelson Ruby 7 04-11-2011 11:23 PM
Design problems (beginner) Michael Judge Ruby 2 01-26-2006 08:14 AM
Beginner Problems simchajoy2000@yahoo.com ASP General 14 01-06-2006 11:45 AM
No Class at ALL!!! beginner/beginner question =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?= ASP .Net 7 02-03-2005 02:47 PM
Tutorial for beginner/ Tutorial voor beginner Rensjuh C++ 7 09-02-2004 12:41 AM



Advertisments