understanding the use of system("cls")

hi...can anyone tell me what is the use of the function ,system("cls"), and fflush()? and when they are used?

First, don't use system().

system() runs a command thru the currently configured shell. In Windows, that means cmd.exe. So if you want to see what the command does, run cmd.exe then type cls. It's the DOS/Windows command for clearing the screen (it came from BASIC).

fflush() flushes a file's buffer to disk. When you work with files (using FILE*), you're dealing with a buffered file. It's buffered to improve performance. But sometimes you want to update the physical file with what's been buffered, it's called flushing the buffer. fflush does that.
If you are getting information about these from the same place, then they are both probably wrong.

Using system() is a dangerous security hole with lots of caveats to proper use. Use wisely.
http://linux.die.net/man/3/system
http://www.cplusplus.com/forum/articles/11153/

Use fflush() only on output streams. It is not defined to work on input streams.
http://linux.die.net/man/3/fflush
http://www.daniweb.com/software-development/cpp/threads/90228

Good luck!
Topic archived. No new replies allowed.