clrscr()
is not a standard function. Visual Studio does not have it. However, MSDN does document how to clear the screen using system("cls")
, or FillConsoleOutputCharacter()
and FillConsoleOutputAttribute()
.
As for the cin
/cout
errors, you need to prefix them with the std::
namespace qualifier, eg std::cin
and std::cout
, or use a separate using namespace std;
statement in your code below the header #include
statements.
Try this:
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <conio.h>
void clrscr()
{
std::system("cls");
}
int main()
{
clrscr();
int no;
std::cout << "Enter a number";
std::cin >> no;
getch();
return 0;
}
Or:
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <conio.h>
using namespace std;
void clrscr()
{
std::system("cls");
}
int main()
{
clrscr();
int no;
cout << "Enter a number";
cin >> no;
getch();
return 0;
}