사용자가 C++에서 숫자를 입력 한 후 화면을 지우고 싶습니다. 콘솔 응용 프로그램 모드에서 프로그래밍 중입니다.C++에서 화면 지우기 명령
어떻게 그렇게 할 수 있습니까? 내 OS는 win7이고 내 IDE는 CodeBlocks이며 컴파일러는 MingWeb입니다.
사용자가 C++에서 숫자를 입력 한 후 화면을 지우고 싶습니다. 콘솔 응용 프로그램 모드에서 프로그래밍 중입니다.C++에서 화면 지우기 명령
어떻게 그렇게 할 수 있습니까? 내 OS는 win7이고 내 IDE는 CodeBlocks이며 컴파일러는 MingWeb입니다.
그것은 당신의 OS의 를 따라 해야 할 것
cout << string(50, '\n');
이 줄은 터미널이 '삭제'된 것처럼 보이는 줄을 인쇄합니다.
그 문제에 대한 좋은 기사 : 당신이 시스템 방법을 일예로 시도 할 수 http://www.cplusplus.com/articles/4z18T05o/
50? 그건 끔찍한 알고리즘입니다! –
은 conio.h
에 정의되어 있습니다. 하지만 물어보기 전에 당신은 왜 구글을 사용하지 않습니까?
system("clear");
당신이 창을 사용하는 경우 :
system("cls");
을하지만,이 응용 프로그램은 휴대리스 확인하는 것이 바람직입니다 당신이 리눅스를 사용하는 경우
Clrscr을 사용하려면 어떤 헤더를 사용해야합니까? – Nofuzy
어떤 IDE를 사용하고 있습니까? –
물어보기 전에 Google에 와서 여기에와주세요. Google은 콘텐츠를 만들지 않으며 색인 생성하여 콘텐츠를 찾을 수 있도록 도와줍니다. –
시스템 ("CLS");
한 가지 방법은 '\ f'(페이지를 꺼내기 위해 라인 프린터에서 사용하는 ASCII 양식 문자, 코드 12에 해당하며 일부 일반 터미널과 에뮬레이터에서 일반 화면으로 인식 함)를 출력하는 것입니다.
Windows에서는 작동하지 않습니다.
#ifdef _WIN32
/* windows hack */
#else
std::cout << '\f' std::flush;
#endif
귀하의 컴파일러에서 conio.h를 링크하십시오. 어떻게하는지 잊어 버렸습니다. 클리어 스크린을 반복해서 사용하는 경우이 기능을 반복해서 사용하십시오. 마이크로 소프트는 콘솔 삭제에 대해 말해야하는거야
enter code here
void clrscr()
{
system("cls");
}
:
#include <windows.h>
void cls(HANDLE hConsole)
{
COORD coordScreen = { 0, 0 }; // home for the cursor
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
// Get the number of character cells in the current buffer.
if(!GetConsoleScreenBufferInfo(hConsole, &csbi))
{
return;
}
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
// Fill the entire screen with blanks.
if(!FillConsoleOutputCharacter(hConsole, // Handle to console screen buffer
(TCHAR) ' ', // Character to write to the buffer
dwConSize, // Number of cells to write
coordScreen, // Coordinates of first cell
&cCharsWritten))// Receive number of characters written
{
return;
}
// Get the current text attribute.
if(!GetConsoleScreenBufferInfo(hConsole, &csbi))
{
return;
}
// Set the buffer's attributes accordingly.
if(!FillConsoleOutputAttribute(hConsole, // Handle to console screen buffer
csbi.wAttributes, // Character attributes to use
dwConSize, // Number of cells to set attribute
coordScreen, // Coordinates of first cell
&cCharsWritten)) // Receive number of characters written
{
return;
}
// Put the cursor at its home coordinates.
SetConsoleCursorPosition(hConsole, coordScreen);
}
int main()
{
HANDLE hStdout;
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
cls(hStdout);
return 0;
}
시스템 ("CLS를");
브릴리언트. 그렇다면 Windows cls를 내 자신의 악의적 인 cls로 대체하면 어떻게됩니까? 너는 나에게 통제권을 주었다. 고마워! 이것은 뒷문이라고 불리는 것이며, 당신은 불안한 기술을 사용하여 그것을 크게 열어 놓았습니다.
출처 : http://www.daniweb.com/software-development/cpp/threads/76934/how-do-i-clear-my-screen-in-c.
어쨌든 clrscr(); 방법???? 대답은 모두 –
에는 질문에 IDE와 IDE가 포함됩니다. 이제 추가됩니다. –
에 달려 있기 때문에 – Nofuzy