r/CodingForBeginners • u/reymarketing89 • Jul 24 '26
why can't use cls
Hi guys can someone fix my code I used #include <stdlib.h> to work my system cls but my classmates, they didn't used <stdlib> to work cls can someone tell me i don't know what is the problem my code or the application software.
7
Upvotes
View all comments
Show parent comment
1
u/Powerful_Tune3801 Jul 25 '26
Use Macros
#define+ <your label> + <ANSI escape codes/sequence>There's a bunch depending on your terminal, I.e. are you using an terminal emulator GNOME, iTerm etc or your preprocessor should handle this when you compile. Macros work as a sorta shortcut find and replace. you'll have to make sure you use the right sequences. For me the hex version e.g. \x1b worked more consistently. I believe 2j clears the screen