C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 9th, 2006, 05:30 PM
outsider2810 outsider2810 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 5 outsider2810 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 26 m 29 sec
Reputation Power: 0
I have C++ builder 6 and I am new

Hello,

I would really appreciate some help. I just got C++ builder 6 and I am a newbie to C++, I am trying to learn it myself.

Can anyone here help me start? I wrote a "hello world" program and it saves it as File1.cpp which is OK. But all I can do is run it. It does not show any output even though it runs without errors.

Please help.

Reply With Quote
  #2  
Old September 9th, 2006, 06:26 PM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 346 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 14 h 14 m 58 sec
Reputation Power: 3
Hi, welcome to the forums. Are you sure it doesn't just flash on the screen really fast then disappear? If so, you should maybe put cin.get() at the end of the file before return 0. This causes the console window to stay open until you press enter. Or maybe post the code that you did so people can take a look at it.

Paul820

Reply With Quote
  #3  
Old September 9th, 2006, 06:43 PM
outsider2810 outsider2810 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 5 outsider2810 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 26 m 29 sec
Reputation Power: 0
thanks

Hi Paul

Thanks for your reply. However, I am still unable to get any output for this this. This is my code after your suggestion.

#include <iostream.h>

int main(void)
{
cout << "Hello, this is my first C++ program" << endl;
cin.get();
return 0;
}

When I run this, the Form designer screen pops up, but there is nothing in there

Reply With Quote
  #4  
Old September 9th, 2006, 09:10 PM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 346 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 14 h 14 m 58 sec
Reputation Power: 3
Hi outsider2810,

#include <iostream> <-- You can drop the .h for C++

int main(void)
{
using namespace std; <-- You must include this for cout and endl etc, unless you use std::cout, std::endl

cout << "Hello, this is my first C++ program" << endl;
cin.get();

return 0;
}

Make sure you are building a console program and not a windows form application.

Reply With Quote
  #5  
Old September 10th, 2006, 01:22 PM
costas costas is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 407 costas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 3 h 19 m 11 sec
Reputation Power: 3
Hey outsider2810,

Don't worry about being a newbie; everyone was. So, in order to help you, I thought it'd be a good idea to show you the first program I wrote!

Code:
#include <iostream>
using namespace std;
using std::cout;

void main()
{
cout<<"Hello World! What's up?";
}

The above program only prints "Hello World!What's up?"; nothing difficult.

Now, a more complicated one(my second one):

Code:
#include <iostream>
using namespace std;
using std::cout;
using std::cin;

void main()
{
int x; // declaration of variable x

cout<<"Please give me one integer number: ";
cin>>x; // system gets the number and stores its value into the variable x
cout<<x; // prints the number; note no "" used
}


This program, now, is getting one integer number from the user and then prints it.

Hope I Helped!!

Costas

Reply With Quote
  #6  
Old September 10th, 2006, 03:24 PM
monkey56657 monkey56657 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 78 monkey56657 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 38 m 21 sec
Reputation Power: 3
Hey just started learning 10 mins ago hehe. what does the void b4 the main function do?

Reply With Quote
  #7  
Old September 10th, 2006, 04:27 PM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 346 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 14 h 14 m 58 sec
Reputation Power: 3
Quote:
Originally Posted by monkey56657
Hey just started learning 10 mins ago hehe. what does the void b4 the main function do?


Read this Bjarne Stroustrup FAQ : void main()

Reply With Quote
  #8  
Old September 11th, 2006, 01:28 PM
outsider2810 outsider2810 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 5 outsider2810 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 26 m 29 sec
Reputation Power: 0
Thanks for the replies guys.

This is so frustrating. I was finally able to get an output but now again, it seems to be messing up. I am doing something wrong, if only I can figure out what it is.

OK, I will explain my problem exactly. These are the steps I follow:

1. I open up C++ builder 6.
2. As soon as I open it up, the following opens up.


3. I close the Form1 window which is right on top. I get this. I wonder how there is some code already present.



4. I delete the already present code and type my "Hello" program instead.

5. I run it and it says that it has compiled over 30,000 lines when my program was hardly 5 lines.

6. I get the following error in the end:



These are linker errors. And yes, I tried all variations suggested by you guys. I don't think its a problem with the code but something else.

I can't figure out what I did to make this run those two times. This makes it more frustrating.

Any help will be appreciated.

PS: What compiler do you guys use? Do you suggest me anything else which is good (and free and downloadable online?). Thanks.

Reply With Quote
  #9  
Old September 11th, 2006, 06:21 PM
ubergeek ubergeek is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 ubergeek User rank is Private First Class (20 - 50 Reputation Level)ubergeek User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 40 m 27 sec
Reputation Power: 4
Send a message via AIM to ubergeek
A great (and free) compiler is Dev-C++, which uses the renowned gcc/g++ as a backend. It is available on bloodshed.net.

Reply With Quote
  #10  
Old September 11th, 2006, 10:00 PM
JimmyDreak JimmyDreak is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Location: Detroit Mi
Posts: 13 JimmyDreak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 21 m 24 sec
Reputation Power: 0
i used to use dev C++, and recently stumbled upon Code::Blocks, and the enviroment is much nicer, so there is just another great free compiler ;p

Reply With Quote
  #11  
Old September 12th, 2006, 08:47 AM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 346 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 14 h 14 m 58 sec
Reputation Power: 3
Code::blocks is a great IDE, cross platform and uses Mingw gcc/g++. I use it and it has nightly builds almost every day. That means it is in development, but still good. RC3 is nearly ready. Dev-cpp is a great IDE, but, sadly it's dead in the water i think. No more development.
There is a wxDEvcpp which comes with the free wxWidgets for doing gui apps: WxDevcpp

Good luck in choosing one.

Reply With Quote
  #12  
Old September 12th, 2006, 09:17 AM
costas costas is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 407 costas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 3 h 19 m 11 sec
Reputation Power: 3
Another great compiler, that unfortunately is not free, is MS Visual C++ (version 6.0 or more).

Reply With Quote
  #13  
Old September 12th, 2006, 01:40 PM
outsider2810 outsider2810 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 5 outsider2810 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 26 m 29 sec
Reputation Power: 0
success!

Finally success! I have downloaded dev-C++ (unfortunately before I came to know about code blocks). I was able to compile my first program! Thanks for all your help.

Reply With Quote
  #14  
Old September 12th, 2006, 05:58 PM
ubergeek ubergeek is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 ubergeek User rank is Private First Class (20 - 50 Reputation Level)ubergeek User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 40 m 27 sec
Reputation Power: 4
Send a message via AIM to ubergeek
Paul: thanks for the wxDevcpp link! I've tried to use wxWidgets with Dev-C++ before, but to no avail. This should work better (haven't tried it yet). And I think you are right about Dev-C++ -- it's been on "5 beta" for a long while now.

Reply With Quote
  #15  
Old September 13th, 2006, 08:38 AM
Paul820 Paul820 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: United Kingdom
Posts: 346 Paul820 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 14 h 14 m 58 sec
Reputation Power: 3
Quote:
Originally Posted by ubergeek
Paul: thanks for the wxDevcpp link! I've tried to use wxWidgets with Dev-C++ before, but to no avail. This should work better (haven't tried it yet). And I think you are right about Dev-C++ -- it's been on "5 beta" for a long while now.


No problem. I can never get wxWidgets to work with code::blocks.
wxDevcpp makes things so much easier.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > I have C++ builder 6 and I am new


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!