2016-04-08 30 views
-2

これは私のコードです!Visual Studio C++、識別子が見つかりません

#include "stdafx.h" 
#include<iostream> 
#include<conio.h> 
void main() 
{ 
clrscr(); 
int no; 
cout<<"Enter a number"; 
cin>>no; 
getch(); 
} 

ここにこのエラーが表示されます。

This is the error I get

私はいくつかの余分なのVisual Studio C++関連のディレクトリをダウンロードする必要がかもしれないと思うが、それでもいくつかの提案は

+1

は 'ようにはstd :: cin'、'のstd :: cout'、としてみてください。 – songyuanyao

+0

http://stackoverflow.com/questions/930138/is-clrscr-a-function-in-c – Mohammad

+1

多くの悪いことがあります。私はC++がどのようにコード化されるべきかを知るためにあなた自身[良いC++ブック](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list)を得ることをお勧めします。 – NathanOliver

答えて

2

clrscr()は標準機能ではありませんしてください。 Visual Studioにはそれがありません。ただし、MSDNは、clear the screenを使用してsystem("cls")、またはFillConsoleOutputCharacter()およびFillConsoleOutputAttribute()を使用してドキュメントを作成します。 cin/coutエラーについては

、あなたはstd::名前空間修飾子、例えばstd::cinstd::coutでそれらを接頭辞、またはヘッダーの下にコード#include文に別々のusing namespace std;ステートメントを使用する必要があります。

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

または::

これを試してみてください

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

を今、あなたのC++プログラムは知らない何clrscr();

この機能を定義する必要があります。それを定義するには、@Remy Lebeauの答えを参照してください。

画面を消去する関数を作成する代わりに、クイックな解決策は、単に空白の束を取り除くことです。

はので、あなたのメインには、単に置くことができます:

std::cout << string(50, '\n'); 
関連する問題