| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 ![]() |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
Hey just started learning 10 mins ago hehe. what does the void b4 the main function do?
|
|
#7
|
|||
|
|||
|
Quote:
Read this Bjarne Stroustrup FAQ : void main() |
|
#8
|
|||
|
|||
|
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. |
|
#9
|
|||
|
|||
|
A great (and free) compiler is Dev-C++, which uses the renowned gcc/g++ as a backend. It is available on bloodshed.net.
|
|
#10
|
|||
|
|||
|
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
|
|
#11
|
|||
|
|||
|
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. |
|
#12
|
|||
|
|||
|
Another great compiler, that unfortunately is not free, is MS Visual C++ (version 6.0 or more).
|
|
#13
|
|||
|
|||
|
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.
|
|
#14
|
|||
|
|||
|
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.
|
|
#15
|
|||
|
|||
|
Quote:
No problem. I can never get wxWidgets to work with code::blocks. wxDevcpp makes things so much easier. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > I have C++ builder 6 and I am new |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|