请问一个清屏的问题!
我用C++(vs2008)做了一个遍历文件夹的程序,每遍历到一个文件就把这个文件的完整路径输出到控制台上。现在想当显示一个完整路径的时候,把前一个显示的路径清掉,请问如何实现?谢谢!
[解决办法]
输出足够长度的空格
[解决办法]
//方法1:#include <conio.h>cprintf("\raaaaaaaaaaaaaaaa");getch();cprintf("\r ");getch();cprintf("\rbbbbbb");getch();//方法2:#include <conio.h>printf("aaaaaaaaaaaaaaaa\n");getch();system("cls");printf("bbbbbb\n");getch();//方法3:#include <windows.h>#include <conio.h>//This will clear the console.void ClearConsole(){ //Get the handle to the current output buffer... HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); //This is used to reset the carat/cursor to the top left. COORD coord = {0, 0}; //A return value... indicating how many chars were written // not used but we need to capture this since it will be // written anyway (passing NULL causes an access violation). DWORD count; //This is a structure containing all of the console info // it is used here to find the size of the console. CONSOLE_SCREEN_BUFFER_INFO csbi; //Here we will set the current color if(GetConsoleScreenBufferInfo(hStdOut, &csbi)) { //This fills the buffer with a given character (in this case 32=space). FillConsoleOutputCharacter(hStdOut, (TCHAR) 32, csbi.dwSize.X * csbi.dwSize.Y, coord, &count); FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, csbi.dwSize.X * csbi.dwSize.Y, coord, &count); //This will set our cursor position for the next print statement. SetConsoleCursorPosition(hStdOut, coord); }}printf("aaaaaaaaaaaaaaaa\n");getch();ClearConsole();printf("bbbbbb\n");getch();(