| jackson6612 (16) | |||||||||||
|
Hi I have seen someone using "clrscr". What's its function? I guess it stands for 'clear screen'. But which screen it want to clear. And what header file to include to make it functional? Please tell me.
I have been told "\n" and "endl" are almost the same but there are some technical differences between the two. Is there also something such as "newl" which is also used for new line? When I want to use "endl" I do it the following way and it works. Using "endl": This will work:
This won't work:
Using "\n": This will work:
This will not work:
Is my observation correct that you have to enclose "\n" within the quotation but "endl" is to be kept outside the quotation marks? Please help me with the above queries. It would be kind of you. Thanks a lot. | |||||||||||
|
Last edited on
|
|||||||||||
| firedraco (4982) | |||
|
1) clrscr() is a non-standard function, don't use it 2) std::endl something you send to a stream that outputs a '\n' character then flushes the buffer 3) '\n' is a special character, different from std::endl, it represents a "newline" (although what that means might be different on your OS)
| |||
|
|
|||
| jackson6612 (16) | |
|
Hi firedraco Thanks for the help. Okay, I won't use "clrscr()" but can you tell what its not-standard function is? And what do you really mean by "non-standard" above? Does it have something to do with C++ and "Standard C++" (although I don't know the distinction between the two). Best wishes Jackson | |
|
|
|
| jackson6612 (16) | |
| Help, please. | |
|
|
|
| ZephyrTR (16) | |
| By non-standart function you can understand that it is not included in C++ libraries. For example the functions you create by yourself are non-standart functions ;) | |
|
|
|
| jackson6612 (16) | |
|
Thanks, ZephyrTR. I also use function "system()" such as "system("pause")", is it also non-standard. And it works without including any header file - although I was told I would need to include "<windows.h>". I'm using Dev-C++. Please guide me on this. Thanks. | |
|
|
|
| lordmat (30) | |||||
|
It is also non-standard due to the fact that it is OS dependent. It would be best to use
This simply waits for the user to press the 'Enter' key. And in some cases where the stream is not cleared, the following will ignore and then wait for the user to press 'Enter' Key.
| |||||
|
|
|||||
| ceruleus (198) | |||
|
jackson- System("command"); is a function call that will make use of any of the commands available in your windows command prompt. Go to StartMenu->Run and type in cmd and hit enter, that will bring up a command prompt. If you type cls into the command prompt and hit enter it will clear the screen of the console. Similarly when you use a System("cls"); call in your code it will clear the console screen at run time. -ceruleus edit: if it is of any help the code for clrscr() would probably be something like this:
| |||
|
Last edited on
|
|||
| wmheric (119) | |
| "The C++ standard" refers to the international ISO C++ standard. If a function/expression/marcro/whatever is in the standard, then it will. But for those not in the standard, it is not guaranteed that they will remain useful (e.g. understandable by new compilers) in, who knows, 10 years time. It is an evolving language. | |
|
|
|
| Duoas (6333) | |
|
BTW, system() is a standard function. You find it by #including <cstdlib>. The problems are that it opens security vulnerabilities, and that it is inherently OS-dependant. For example system("cls");will only work on Windows. On Unix, you would have to say system("clear");and hope it works. | |
|
|
|