Novice C language learning journey(9)

avatar

梦幻光晕蓝色背景矢量图.png
How to delete the content of outputted?I want to delete the content of '*' on console.I used the "\b" on the printf statement.But the code can not implement this function.Because it delete one line only.The code as follows:

   #include"stdio.h"
   #include"stdlib.h"
   #include"windows.h"
   #include"stdio.h"
   main(){
   int i,j,k;
   k=0;
   char a[2][2]={{'*','*'},{'*','*'}};  
   for(i=0;i<=1;i++){
     for(j=0;j<=1;j++){     
           printf("%c",a[i][j]);
   }
   if(k>=1)
   ;
   else
       printf("\n");
   k++;
   }
   Sleep(2000);
   printf("\b\b\b\b    \n");
   system("pause");
   }

No long after,I found it can implement the function when added the statement of "system("cls")".The modified as follows:

   #include"stdio.h"
   #include"stdlib.h"
   #include"windows.h"
   #include"stdio.h"
   main(){
   int i,j,k;
   k=0;
   char a[2][2]={{'*','*'},{'*','*'}};  
   for(i=0;i<=1;i++){
      for(j=0;j<=1;j++){     
          printf("%c",a[i][j]);
   }
   if(k>=1)
   ;
   else
       printf("\n");
   k++;
   }
   Sleep(2000);
   printf("\b\b\b\b    \n");
   Sleep(2000);
   system("cls");
   system("pause");
   }


0
0
0.000
0 comments