Thread: Hello World in C++ with CodeLite

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    30

    Hello World in C++ with CodeLite

    Hello,
    I am using Codelite compiler Version: V2.7.0.4375 (latest) and trying to compile a simple hello world program:
    Code:
    #include <stdio.h>
    
    int main(int argc, char **argv)
    {
    	cout << "Hello World\n";
    	return 0;
    }
    When I compile this program I am getting error:
    "'cout' was not declared in this scope".
    Anybody has any idea about this ?

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    using iostream library (include)

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Two things: as rodrigorules said, where this is C++ you need to #include <iostream>, not <stdio.h>. You also need to declare that you're using the std namespace by adding
    Code:
    using namespace std;
    before you use cout.

  4. #4
    Registered User
    Join Date
    Jul 2010
    Posts
    30

    Unhappy

    Thanks for your responses. I tried following thing, but does not seems to be working either.
    Code:
     
    
    #include <iostream.h>
    
    using namespace std;
    
    int main(int argc, char **argv)
    {
    	cout <<"Hello World";
    	return 0;
    }
    This time I get the error, "iostream.h" No such file or directory and 'cout' was not declared in this scope.
    Any clue about this ??

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Two people have told you it's #include <iostream>, not #include <iostream.h> and that error message makes no sense to you?

  6. #6
    Registered User
    Join Date
    Jul 2010
    Posts
    30

    Smile

    Yeah that worked. Thanks..

  7. #7
    Registered User arc_angel14's Avatar
    Join Date
    Sep 2010
    Location
    USA
    Posts
    18
    you could make it shorter by going
    Code:
     
    
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	cout <<"Hello World.\n"
    	return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The 7 New Wonders of the World
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 36
    Last Post: 12-08-2006, 01:55 PM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  3. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  4. Too much to ask ?
    By deflamol in forum C Programming
    Replies: 2
    Last Post: 05-06-2004, 04:30 PM
  5. No More Technology After World War Three
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-20-2001, 07:02 PM