This is my code:
#include <iostream>
using namespace std;
int main ()
{
int edad;
string nombre;
cout<<"Hola mundo"<<endl;
cout<<"Como estan?"<<endl;
cout<<"Ingresa tu edad"<<endl;
cin>>edad;
cout<<"Ingresa tu nombre"<<endl;
cin>>nombre;
//Digamos que la persona ingreso numeros en el nombre
//Quiero borrar la ultima parte y no todo
return 0;
}
What I want to do is delete a line from the console, the above is just an example.
Bottom line I don't want to do system ("cls")
just erase a part of the screen.
How do i do it?
You can use
cout<<"\e[A";
but in your case when printing the last line you useendl
, you would have to use this instruction twice:You would have as output only:
What it does when outputting
"\e[A"
is a history-search backward .I solved this problem using a combination of the function gotoxy and system("clear") here is the code for the function gotoxy x if anyone else needs it:
Don't forget to add the windows.h and stdlib.h libraries , with that you can create functions with loops to clean parts of the screen