Using Borland C++ builder 5

This is a discussion on Using Borland C++ builder 5 within the C++ Programming forums, part of the General Programming Boards category; hi. well, i'm an absolutely newbie in c++. i'm just about to learn it. now i want to practice it. ...

  1. #1
    Ryan |2yan's Avatar
    Join Date
    Sep 2004
    Posts
    6

    Using Borland C++ builder 5

    hi. well, i'm an absolutely newbie in c++. i'm just about to learn it. now i want to practice it. the problem is, the institute (NIIT) teaches me using linux, and i use windows. i'm currently downloading 'cygwin' to somehow simulate the experience but in the meantime, how would i compile programs using borland. whenever i try to compile it, it gives me errors. i honestly don't know what is wrong. here is one simple code i'm trying to compile in borland:
    Code:
    #include<iostream>
    void main()
    {
       cout<<"Wassup!";
    };
    Now i'm running into two problems. first, when i use the 'run' command, it gives me this error:[C++ Error] File1.cpp(4): E2451 Undefined symbol 'cout'. Secondly, i want the program to show the output, in this case it would be 'wassup.' So how do i do that. i'm sorry if this has been asked before but this is my first time and i have no idea what i'm doing wrong or how to fix or debug it. thanks for any help.. and i'm sure i'll be asking more questions as i become better in code. hehe

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    Code:
    #include<iostream>
    int main()
    {
        std::cout<<"Wassup!";
        return 0;
    }
    Or do this:

    Code:
    #include<iostream>
    using std::cout;
    
    int main()
    {
        cout<<"Wassup!";
        return 0;
    }
    Or if you don't want to explicitly qualify everything you can just put using namespace std; underneath the #include line.

    Code:
    #include<iostream>
    using namespace std;
    
    int main()
    {
        cout<<"Wassup!";
        return 0;
    }
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Here we go..
    Code:
    #include <iostream>
    
    int main(void)//main should never be void it should always return an int
    {
      std::cout<<"Wassup!";//need to add the std:: in front of cout
      std::cin.get();//This will answer your next question on why it opens and closes
      return 0;//as I said main needs to return an int
    }
    And thats it welcome to the boards and c++
    Woop?

  4. #4
    Ryan |2yan's Avatar
    Join Date
    Sep 2004
    Posts
    6
    ok thanks. that helped. and how would i get the compiler to show the output Wassup!.

  5. #5
    Ryan |2yan's Avatar
    Join Date
    Sep 2004
    Posts
    6
    ok but why shouldn't we use 'void'?

  6. #6
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    You could run the .exe
    Woop?

  7. #7
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Because its not part of the standard. There is some systems where it is necesarry but if you don't know if your using one then use int main()(I read the last part somewhere probably prelude )
    Woop?

  8. #8
    Ryan |2yan's Avatar
    Join Date
    Sep 2004
    Posts
    6
    oh ok. all right, i'll use int from now on. hehe. and uh.. ok i guess this is a dumb question, the file extension is .cpp and it's in project1.exe. so do i just run project1.exe to show the output or what? sorry this may seems like a stupid question.

  9. #9
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Yep you should just run the exe file to see the output
    Woop?

  10. #10
    Ryan |2yan's Avatar
    Join Date
    Sep 2004
    Posts
    6
    ok lol. sorry but i can't seem to get the output to run. when i click on file>new.. (by the way, the c++ file is all ready saved on my desktop), what do i select? application, batch file, cpp file?? and i have added this file to a previous project but when i try to run it, nothing comes up.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. THE END - Borland C++ Builder, Delphi, J Builder?
    By Davros in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 02-28-2006, 10:23 PM
  2. Converting from Borland Builder -> MSVC++ guide?
    By _Elixia_ in forum Windows Programming
    Replies: 4
    Last Post: 08-02-2003, 09:00 AM
  3. TAutoObject: Builder 1.0 vs. 6.0
    By pimming in forum C++ Programming
    Replies: 2
    Last Post: 06-11-2003, 10:47 PM
  4. Dynamically programme in C++ Builder..Help
    By Gugge in forum C++ Programming
    Replies: 2
    Last Post: 08-01-2002, 12:14 PM
  5. borland c++ builder 6 trial
    By Klinerr1 in forum C++ Programming
    Replies: 3
    Last Post: 06-12-2002, 11:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21