Thread: Error in sourcecode

  1. #1
    C++, using Dev C++
    Join Date
    May 2004
    Posts
    7

    Error in sourcecode

    Hi,

    Iam trying to compile a code but I get error can anyone here help me?

    #include <iostream>
    using namespace std;
    // Function prototype
    void DisplayAge(int nAge);

    int main()
    {
    DisplayAge(42);
    return 0;
    }

    void DisplayAge(int nAge)
    {
    cout << "Hello World! I'm " << nAge << " years old." endl;
    }

  2. #2
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    Firstly, you should probably tell us what your error is.

    But at a guess, I would say that you've forgotten the << operator before the endl in your code.
    Code:
     cout << "Hello World! I'm " << nAge << " years old." endl;
    Should be..
    Code:
     cout << "Hello World! I'm " << nAge << " years old." << endl;

  3. #3
    C++, using Dev C++
    Join Date
    May 2004
    Posts
    7

    thanyou

    Firstly, you should probably tell us what your error is.
    OK sorry I will do that next time. Now that code works thanks for the help

    /AndreasN

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to read multifiles sourcecode like games engines
    By kariem2k in forum C++ Programming
    Replies: 1
    Last Post: 03-16-2003, 10:37 AM