Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem in my first program...

Problem in my first program...

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X xelios

    I am a newbie and this is my first program...

    // test.cpp : Defines the entry point for the console application.
    //

    #include "stdafx.h"
    #include "conio.h"
    #include "stdio.h"

    int _tmain(int argc, _TCHAR* argv[])
    {
    cout << "Hello!";
    return 0;
    }

    But when I built, it thre follwong error... Error 1 error C2065: 'cout' : undeclared identifier e:\visual programming\practices\test\test\test.cpp 11 test

    Mohsin Ali

    J Offline
    J Offline
    Jijo Raj
    wrote on last edited by
    #2

    Cout is declared in iostream header.

    #include "iostream"
    using namespace std;

    Regards, Jijo.

    _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

    1 Reply Last reply
    0
    • X xelios

      I am a newbie and this is my first program...

      // test.cpp : Defines the entry point for the console application.
      //

      #include "stdafx.h"
      #include "conio.h"
      #include "stdio.h"

      int _tmain(int argc, _TCHAR* argv[])
      {
      cout << "Hello!";
      return 0;
      }

      But when I built, it thre follwong error... Error 1 error C2065: 'cout' : undeclared identifier e:\visual programming\practices\test\test\test.cpp 11 test

      Mohsin Ali

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #3

      cout is part of the std namespace, so either write std::cout or put a using namespace std on top of your file (after the header file inclusion). Another point: conio.h and stdio.h are for C. If you are using cout (which is part of the C++ standard library), you should #include <iostream> instead.

      Cédric Moonen Software developer
      Charting control [v1.4]

      1 Reply Last reply
      0
      • X xelios

        I am a newbie and this is my first program...

        // test.cpp : Defines the entry point for the console application.
        //

        #include "stdafx.h"
        #include "conio.h"
        #include "stdio.h"

        int _tmain(int argc, _TCHAR* argv[])
        {
        cout << "Hello!";
        return 0;
        }

        But when I built, it thre follwong error... Error 1 error C2065: 'cout' : undeclared identifier e:\visual programming\practices\test\test\test.cpp 11 test

        Mohsin Ali

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #4

        mohsindeveloper wrote:

        #include "stdio.h"

        Hint: Stdio.h is for C-Style input output routines. Can you guess what header has the prototypes for C++ style input output routines? :) [Add: Oh my Gawd! Two people beat me to it already :) ]

        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

        1 Reply Last reply
        0
        • X xelios

          I am a newbie and this is my first program...

          // test.cpp : Defines the entry point for the console application.
          //

          #include "stdafx.h"
          #include "conio.h"
          #include "stdio.h"

          int _tmain(int argc, _TCHAR* argv[])
          {
          cout << "Hello!";
          return 0;
          }

          But when I built, it thre follwong error... Error 1 error C2065: 'cout' : undeclared identifier e:\visual programming\practices\test\test\test.cpp 11 test

          Mohsin Ali

          M Offline
          M Offline
          Maxim Zarus
          wrote on last edited by
          #5

          Add this header file

          #include <iostream>

          And also write cout as

          std::cout<<"Hello!";

          1 Reply Last reply
          0
          • X xelios

            I am a newbie and this is my first program...

            // test.cpp : Defines the entry point for the console application.
            //

            #include "stdafx.h"
            #include "conio.h"
            #include "stdio.h"

            int _tmain(int argc, _TCHAR* argv[])
            {
            cout << "Hello!";
            return 0;
            }

            But when I built, it thre follwong error... Error 1 error C2065: 'cout' : undeclared identifier e:\visual programming\practices\test\test\test.cpp 11 test

            Mohsin Ali

            X Offline
            X Offline
            xelios
            wrote on last edited by
            #6

            Yuppeee!! Program has built....... Now how can I run it.. i.e. I want to see the output of my program..

            Mohsin Ali

            M 1 Reply Last reply
            0
            • X xelios

              Yuppeee!! Program has built....... Now how can I run it.. i.e. I want to see the output of my program..

              Mohsin Ali

              M Offline
              M Offline
              Maxim Zarus
              wrote on last edited by
              #7

              Either add getche() before return statement and press F5. or Go to command prompt and run your program exe directly.

              X 1 Reply Last reply
              0
              • X xelios

                I am a newbie and this is my first program...

                // test.cpp : Defines the entry point for the console application.
                //

                #include "stdafx.h"
                #include "conio.h"
                #include "stdio.h"

                int _tmain(int argc, _TCHAR* argv[])
                {
                cout << "Hello!";
                return 0;
                }

                But when I built, it thre follwong error... Error 1 error C2065: 'cout' : undeclared identifier e:\visual programming\practices\test\test\test.cpp 11 test

                Mohsin Ali

                A Offline
                A Offline
                Akt_4_U
                wrote on last edited by
                #8

                Press Ctrl+F5

                akt

                1 Reply Last reply
                0
                • M Maxim Zarus

                  Either add getche() before return statement and press F5. or Go to command prompt and run your program exe directly.

                  X Offline
                  X Offline
                  xelios
                  wrote on last edited by
                  #9

                  Error!!! Error 1 error C3861: 'getche': identifier not found e:\visual programming\practices\test\test\test.cpp 13 test

                  Mohsin Ali

                  M 1 Reply Last reply
                  0
                  • X xelios

                    Error!!! Error 1 error C3861: 'getche': identifier not found e:\visual programming\practices\test\test\test.cpp 13 test

                    Mohsin Ali

                    M Offline
                    M Offline
                    Maxim Zarus
                    wrote on last edited by
                    #10

                    to use getche() you will have to use #include <conio.h> by the way you should choose second option.

                    X 1 Reply Last reply
                    0
                    • M Maxim Zarus

                      to use getche() you will have to use #include <conio.h> by the way you should choose second option.

                      X Offline
                      X Offline
                      xelios
                      wrote on last edited by
                      #11

                      Thx its done............. Bingoo! :cool:

                      Mohsin Ali

                      modified on Tuesday, June 3, 2008 9:10 AM

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups