Thread: Code Compile

  1. #1
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321

    Code Compile

    Hi peeps.
    I just wrote a program because im bored.
    Here is the code:

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
    	int DOB;
    	cout << "Please enter your date of birth...\n" << endl;
    	cin >> DOB
        cin.ignore();
    	if (DOB < 2006) {
    		cout << "Erh, you were not born in this year!\n" << endl;
    		}
    	else if (DOB == 2006) {
    		cout << "Oioi, howz your first year?\n" << endl;
    		}
    	else {
    		cout << "WTF are you on aboot? You arn't even born yet!\n" << endl;
    		}
    	cin.get();
    }
    But im just wondering how to compile it, can anyone help me?
    I'm using Visual C++ 2005 express edition.
    Last edited by beene; 08-08-2006 at 10:13 AM.

  2. #2
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    I am posting this because you did not use code tags on this thread. In the furture please use Code Tags. They make your code MUCH easier to read and people will be much more likely to help you if you do. And they'll be happier about helping you

    For example:

    Without code tags:

    for(int i=0;i<5;i++)
    {
    cout << "No code tags are bad";
    }

    With Code Tags:
    Code:
    for(int i=0;i<5;i++)
    {
         cout << "This code is easy to read";
    }
    This is of course a basic example...more complicated code is even easier to read with code tags than without.

    I've added code tags for you this time. They can be added by putting [code] at the beginning of your code and [/code] at the end. More information on code tags may be found on the code tag post at the top of every forum. I also suggest you take a look at the board guildlines if you have not done so already.

    This is a common first post mistake, just remember to use [code] tags in the future and you'll get much more help.

    If this is your first time posting here the welcome, and if there's anything I can do or any questions I can answer about these forums, or anything else, please feel free and welcome to PM me.


    Good Luck with your program,

    Kermi3
    Lead Moderator


    edit: Errr it appaers you just mistuped them. In the bottom the '/' goes before "code". Sorry about that.
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  3. #3
    !anExpert
    Join Date
    Mar 2005
    Location
    pa
    Posts
    155
    >But im just wondering how to compile it, can anyone help me?

    did you create a new project or a new file. iirc you cant compile a file by itself, you have to create a project before you can compile anything.

    if you are just starting out id suggest checking out dev c++, its a little easier to get started with.

    http://bloodshed.net

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Open VC++ 2005. Create a new project. Select Win32 Console Application and give the project a name. In the wizard that appears, check the Empty Project box on the Application Settings page.

    When the project is created, right-click on the project and add a new file. Select cpp file. Paste your code into the cpp file and save it. Then build your solution (F7) and execute it (Ctrl-F5) or run it through the debuger (F5).

  5. #5
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    hi, and ty, i've just used dev c++ and tried to compile it, but i had a few problems, can anyone help me, i have no idea how to fix the errors

  6. #6
    !anExpert
    Join Date
    Mar 2005
    Location
    pa
    Posts
    155
    that depends, are you going to post what the errors say?

  7. #7
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    DOB.cpp:9: ambiguous overload
    for `std::istream& >> std::istream&' operator

    DOB.cpp:9: parse error before `
    .' token

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    cout << "Please enter your date of birth...\n" << endl;
    cin >> DOB
    cin.ignore();

    Missing semicolon.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    lol, no there aint

  10. #10
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    oh, yes there is, i'm really sorry!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code won't compile
    By monkles in forum C Programming
    Replies: 3
    Last Post: 05-28-2009, 01:45 PM
  2. Compile Errors in my Code. Can anyone help?
    By DGLaurynP in forum C Programming
    Replies: 1
    Last Post: 10-06-2008, 09:36 AM
  3. This code won't compile in Red Hat Linux 9
    By array in forum Linux Programming
    Replies: 7
    Last Post: 04-27-2004, 06:30 AM
  4. << !! Posting Code? Read this First !! >>
    By kermi3 in forum Linux Programming
    Replies: 0
    Last Post: 10-14-2002, 01:30 PM
  5. How do they compile code for an OS ?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 49
    Last Post: 03-28-2002, 12:16 AM