Thread: Very Beginner Question

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    5

    Very Beginner Question

    Hi, I tried a tutorial and I am using Borland C++. I can't get it to run. Here is the source code :

    Code:
    //---------------------------------------------------------------------------
    
    #include <vcl.h>
    #pragma hdrstop
    
    #include "Unit1.h"
    #include <iostream.h>
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    int main()
    {
      cout<<"HEY, you, I'm alive!  Oh, and Hello World!";
      return 0;
    }
    //---------------------------------------------------------------------------
    Any help would be great. Thanks

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    The problem is that you are trying to create a console program in a VCL app. When BCB opens up, do a "Close All", and then "New -> Console Wizard" (or "Console App" or something, depending on version). Then put your code there.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    5

    Okay

    Thanks. I still can't run the program so I am obviously having some horrible errors. Is there a better place to start since the beginner tutorial isn't working? Hah..

  4. #4
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Post your current code.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  5. #5
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    You could try the tutorials on cprogramming.com. Although they are somewhat outdated, they are still better than the ones you were reading...I don't know what that tutorial you were looking at is trying to accomplish, but it seems to have unnecessary lines of code and is also outdated. Here's a simple example program:
    Code:
    #include <iostream>
    
    int main()
    {
    std::cout<<"Hello world!";
    }
    That should compile fine, assuming you have an up-to-date compiler.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  6. #6
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    If you are learning c++ from scratch, drop the book you have there and learn the fundementals first.
    Here are 2 good tutorials to get you on your way.

    http://www.cplusplus.com/doc/tutorial

    sams c++ 21days
    Swap the 21days to 21weeks for a more realisitic idea timescale.

  7. #7
    Registered User
    Join Date
    Jan 2004
    Posts
    5
    Code:
    //---------------------------------------------------------------------------
    
    #include <iostream>
    
    int main()
    {
    std::cout<<"Hello world!";
    }
    
    //---------------------------------------------------------------------------
    With Borland that gives me the error, in console wizard mode, that says :
    "[Linker error] Unresolved external '__InitVCL' referenced from C:\...\Lib\CP32MTI>LIB|crtlvcl
    "[Linker error] Unresolved external '__ExitVCL' referenced from C:\...\Lib\CP32MTI>LIB|crtlvcl"

  8. #8
    Registered User o0o's Avatar
    Join Date
    Dec 2003
    Posts
    37

    Arrow try this one/

    y? don't u try this code.

    Code:
    #include<iostream>
    #include<conio.h>
    
    using std::cout;
    using std::endl;
    
    int main()
    {
        // display hello world message
        
        cout<< "Hello World:" <<endl;    
    
    getch();
    
    }
    Last edited by o0o; 01-09-2004 at 07:38 AM.

  9. #9
    Registered User
    Join Date
    Jan 2004
    Posts
    5

    Woo!

    I got it to work. I had to uncheck VCL/CLX. I tried switching between the two instead of actually disabling both. It works now. Only think is that it closes before I can see it. How can I fix that?

  10. #10
    Registered User o0o's Avatar
    Join Date
    Dec 2003
    Posts
    37

    Lightbulb #include<cstdlib> is missing pal/

    The only prob u r facing at the moment is that your system doesn't pause so that u can see the output.

    here try to include cstdlib in ur code.

    Code:
    #<iostream>
    #include<cstdlib> // in older version try stdlib.h
    int main()
    {
    
    code
    
    system("PAUSE"); // pause the system to see output
    return 0;
    
    }

  11. #11
    Registered User
    Join Date
    Jan 2004
    Posts
    5

    Awesome

    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner: Linked List question
    By WeatherMan in forum C++ Programming
    Replies: 2
    Last Post: 04-03-2008, 07:16 AM
  2. Quick IF statement question (beginner)
    By jim.rattlehead in forum C Programming
    Replies: 23
    Last Post: 11-29-2007, 06:51 AM
  3. beginner question
    By Barrot in forum C++ Programming
    Replies: 4
    Last Post: 08-19-2005, 02:17 PM
  4. Question About External Files (Beginner)
    By jamez05 in forum C Programming
    Replies: 0
    Last Post: 08-11-2005, 07:05 AM
  5. Beginner on Win32 apps, lame question.
    By Templario in forum C Programming
    Replies: 3
    Last Post: 11-06-2002, 08:39 PM