Delete a printed character from console


#include<stdio.h>
int main ()
{
char c;
for (c = 'A' ; c <= 'Z' ; c++) putchar (c);

return 0;
}

it will print characters from 'A' to 'Z' on console.

now I want to delete those characters one by one for example
if i press 'backspace key' it deletes the 'Z' character and so on if i keep pressing
Last edited on
You'll have to play with it to get the results you want.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <conio.h>
#include <stdio.h>
int main ()
{
char c;
int count=0;
int x;

for (c = 'A' ; c <= 'Z' ; c++) 
	{
	putchar (c);
	}
	getch();
	printf("\b "); // Removes Z
//	printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b                         "); // leaves A 
//	printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b                        "); // leaves A and Z
	
return 0;
}
Last edited on
Thanks SamuelAdams It worked with

cout<<"\b \b";
Last edited on
Topic archived. No new replies allowed.