Addition Program using Ms Visual Studio 2010 C++

Hi, I run the following program well in Borland, but when I copy the whole code to Visual, it cannot detect something like conio, cin, cout...May I know why will this happen in Visual Studio 2010 C++? Thanks...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <conio>

int main()
{
	int a,b,c;


   cin>>a;
   cin>>b;
   c=a+b;
   cout<<"The value c is \n"<<c;
   getch();
   return 0;
}
Shouldn't it be #include <conio.h> ? Not sure if that will work because conio is not a standard header and I don't know if Visual Studio has it preinstalled.
Last edited on
Visual Studio has it, and you are correct. It's #include <conio.h>

EDIT:
Aslo, getch() is deprecated, instead, use _getch().
http://msdn.microsoft.com/en-us/library/ms235446%28v=vs.80%29.aspx
Last edited on
Ya, u both are right, after put ".h" then only it can function, i wonder why Visual studio have to be like this, lolx...

but how to solve for the cout and cin problem? This are the error I got

error C2065: 'cin' : undeclared identifier
error C2065: 'cin' : undeclared identifier
error C2065: 'cout' : undeclared identifier
1
2
3
4
std::cin>>a;
std::cin>>b;
c=a+b;
std::cout<<"The value c is \n"<<c;
Hi Peter, thanks for it, I just know that Visual need namespace std in order for cin, cout and endl to works fine...The following code would works as well...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
	int a,b,c;


   cin>>a;
   cin>>b;
   c=a+b;
   cout<<"The value c is \n"<<c<<endl;

   _getch();
   return 0;
}


Is that using namespace std; together with#include <iostream> can be use for printf and scanf as well? Or need #include<stdio> ? Thanks...
Topic archived. No new replies allowed.