Sorry for the bad title, but I'm not even sure what I'm trying to do is called. I have about 10 lines of code to clear a screen and reprint only certain images back to erase clutter. The thing is, I'm just simply tiered of writing these ten lines over and over and over and over again. It's cluttering up main.cpp and making me confused.

I wanted to do something like this:

void clearJunk(){

//my code here

}

Then in the dozens of places I need to run this code in main.cpp, I would just do:

clearJunk();

Or maybe use classes instead of wrappers. But the problem is that this just doesn't work. It returns with handfuls of declaration problems and whatever else my complier likes to complain about.

Can someone tell me a good way to do what I'm trying to do? thanks :)

Recommended Answers

All 3 Replies

How to erase the screen is operating system dependent. The simplest way to do it is system("cls"); or for *nix syte("clear"); But both those are not recommended because they can intoduce your program to hackets.

Yes it is possible, it's known as a function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.