question about STL

This is a discussion on question about STL within the C++ Programming forums, part of the General Programming Boards category; Hi, there, I got a question about STL that bothers me a lot. I cannot even do this simple one, ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    2

    question about STL

    Hi, there,

    I got a question about STL that bothers me a lot.

    I cannot even do this simple one,

    #include <iostream>
    void main()
    {
    cout << "Hello World" << endl ;
    }

    It gave me this:

    Compiling...
    1.cpp
    E:\temp\1.cpp(5) : error C2065: 'cout' : undeclared identifier
    E:\temp\1.cpp(5) : error C2297: '<<' : illegal, right operand has type 'char [12]'
    E:\temp\1.cpp(5) : error C2065: 'endl' : undeclared identifier
    Error executing cl.exe.

    1.obj - 3 error(s), 0 warning(s)

    I know it's problem with STL, but don't know what on earth is wrong. I have the library files for STL, such as LIBCP.LIB, LIBCPMT.LIB, MSVCPRT.LIB, LIBCPD.LIB, etc, in the directory of 'C:\Program Files\Microsoft Visual Studio\VC98\LIB' or 'C:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB'.

    Do I need to set anything up in VC++. Btw, I'm using MSVC++ 6.0.

    Thanks a lot.

    Joe

  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    First off, before anyone yells at you, make sure you do int main() since void main() is bad bad bad!

    Second, put the line "using namespace std;" after your first line and your program should work fine.

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    2
    Thanks a lot. It works.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. STL list.sort() question
    By dudeomanodude in forum C++ Programming
    Replies: 14
    Last Post: 01-23-2008, 01:48 PM
  2. Design layer question
    By mdoland in forum C# Programming
    Replies: 0
    Last Post: 10-19-2007, 04:22 AM
  3. STL preformance question
    By l2u in forum C++ Programming
    Replies: 9
    Last Post: 12-07-2006, 04:36 PM
  4. STL algorithm question
    By Reggie in forum C++ Programming
    Replies: 1
    Last Post: 04-22-2003, 09:04 AM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM

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