Find the answer to your Linux question:
Results 1 to 2 of 2
Code: #include <iostream> int main&#40;&#41; &#123; cout << "Helllo, have fun with C++" ; return&#40;0&#41;; &#125; the program is named "first.cc" compiled the program with C++ first.cc Following were the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2003
    Location
    Bangkok
    Posts
    2

    C++ configuring (error attached ) pls help


    Code:
    #include <iostream>
    int main&#40;&#41;
    &#123;
       cout << "Helllo, have fun with C++" ;
       return&#40;0&#41;;
    &#125;
    the program is named "first.cc"
    compiled the program with C++ first.cc

    Following were the errors

    C++ first.cc
    first.cc : In function int main()':
    first.cc:4: 'cout' undeclared (first use this function)
    first.cc:4Each undeclared identifier is reported only once for each function it appears in.)

  2. #2
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    What compiler version are you running? I'm guessing that it's above gcc2.95. Try this instead:
    Code:
    #include <iostream>
    using namespace std;
    
    int main&#40;&#41;
    &#123;
      cout << "Hello Bankok!!\n";
    
      // Question, does return&#40;0&#41; work?
      return 0;
    &#125;
    If you want an explanation, please ask for one. I'm rather tired at this time but I will explain it tomorrow or so if asked.
    The best things in life are free.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •