Problem in my first program...
-
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
-
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
-
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
cout is part of the std namespace, so either write
std::cout
or put ausing 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] -
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
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
-
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
Add this header file
#include <iostream>
And also write cout as
std::cout<<"Hello!";
-
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
-
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
-
Yuppeee!! Program has built....... Now how can I run it.. i.e. I want to see the output of my program..
Mohsin Ali
Either add
getche()
beforereturn
statement and press F5. or Go to command prompt and run your program exe directly. -
Either add
getche()
beforereturn
statement and press F5. or Go to command prompt and run your program exe directly. -
Error!!!
Error 1 error C3861: 'getche': identifier not found e:\visual programming\practices\test\test\test.cpp 13 test
Mohsin Ali
to use
getche()
you will have to use#include <conio.h>
by the way you should choose second option. -
to use
getche()
you will have to use#include <conio.h>
by the way you should choose second option.