Question

This is a discussion on Question within the C++ Programming forums, part of the General Programming Boards category; I'm doing the Learn C++ in 21 days tutorial found here. I'm using Dev-C++ as my compiler. When I write ...

  1. #1
    Registered User Fool's Avatar
    Join Date
    Aug 2001
    Posts
    335

    Question

    I'm doing the Learn C++ in 21 days tutorial found here. I'm using Dev-C++ as my compiler. When I write the code exactly as they have it in the book the compiler still finds errors. IE:

    // Listing 2.2 using cout

    #include <iostream.h>
    int main()
    {
    cout<<"Hello there.\n";
    cout<<"Here is 5: " << 5 << "\n";
    cout<<"The manipulator endl writes a new line to the screen." <<
    endl;
    cout<<"Here is a very big number:\t" << 70000 << endl;
    cout<<"Here is the sum of 8 an 5:\t" << 13 << endl;
    cout<<"Here's a fraction:\t\t" << (float) 5/8 << endl;
    cout<<"And a very very big number:\t" << (double) 7000 * 7000 <<
    endl;
    cout<<"Don't forget to replace Jesse Liberty with your name...\n";
    cout<<"Chris Stewart is a C++ programmer!\n";
    return 0;
    }
    It's just like the book said but the compiler finds errors. Right here is where I am (under "A Brief Look at cout"). Any ideas?

    -Fool

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Make it a console application, rather than a windows app, and it will be fine.

    Also, you may want to put something like..

    char wait; cin >> wait;

    before the return statement, so the program will wait for you to press a key and enter before it closes so you can read the output.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Registered User Fool's Avatar
    Join Date
    Aug 2001
    Posts
    335
    It is a console app.

    -Fool

  4. #4
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    Change this:
    Code:
    cout<<"The manipulator endl writes a new line to the screen." << 
    endl;
    To this in both places:
    Code:
    cout<<"The manipulator endl writes a new line to the screen." << endl;
    I compile code with:
    Visual Studio.NET beta2

  5. #5
    Unregistered
    Guest
    change
    Code:
    cout<<"Here is 5: " << 5 << "\n";
    to
    Code:
    cout<<"Here is 5: " << "5" << "\n";
    or declare the variables like this:
    Code:
    int 5='5';
    that should work, then repeat either of the two steps on all the other cout messages that include numbers.

    also make sure verything else is declared such as: float, int, char, etc...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 03:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 06:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 01:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM

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