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

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;
};

hey!! thanks!!!!!! it is working!!!
thank you very much!

yes, you need to use namespace std

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.