0

hi guys.. i am new to c++ and i am having a problem running it couz it usually says:

11 C:\Dev-Cpp\conio_test1.cpp `cout' undeclared (first use this function)

this is my code and please try to help me!

#include<iostream>
#include<conio.h>

int main()
{
     int a =0;
     while(!kbhit())
     {
                   printf("%a \t", a);
                   a++;
                   cout<<a;
     }
 getch();
 return(0);
}

by the way i am using dev-c++ as my compiler

Edited by awah mohamad: n/a

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by sashankalladi
0

cout is in the std namespace. You need to either qualify it fully, like so:

#include <iostream>

int main() {
  std::cout << "Hello World!" << std::endl;
};

Or, you can issue a "using namespace std;" statement, as so:

#include <iostream>

using namespace std;

int main() {
  cout << "Hello World!" << endl;
};
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.