Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear:
I want to create my own function in c which function is to clear the screen i know their is an already predefine function clrscr() but i want to make it own can anyone help me please.
Thanks
Posted
Updated 29-Aug-13 9:46am
v2
Comments
[no name] 29-Aug-13 15:54pm    
You would need to ask a question or describe some sort of a problem before you could reasonably expect any kind of help.
enhzflep 29-Aug-13 16:44pm    
"can anyone help me please." Looks mighty like a question to me - even if the punctuation leaves something to be desired..
Mufasil Muhammad Iqbal 30-Aug-13 2:30am    
Sir i have made this program " #include #include void clr(void); void clr(void) { clrscr(); } int main() { clr(); printf("Hi"); getch(): return(0); } " now i make this program and submit it to my sir he says you cant use clrscr(); function in your program you have to create your own clrscr(); function name clr(); with help of gotoxy(); function in c in turbo c so can you tell me how i do this even can you tell me the concept how clrscr(); function runs?
enhzflep 29-Aug-13 16:52pm    
You make mention of clrscr() - that makes me think you're using (16-bit) TurboC, Is that the case? If so, you can simply write 80x25x2 bytes to the memory at 0xB8000.

I.e
char unsigned *textModeBuffer = 0xB8000;
memset(textModeBuffer, 0, 80*25*2);

If you're not using TurboC and making 16bit programs, you may wish to look into the Console Functions page at MSDN: MSDN: Console Funtions

Here's another post on more-or-less the same thing - I had to look it up, sine it's been so long since I could directly access memory like this, that I'd forgotten.
Where is the text-mode video buffer

OT: (Though I can tell you that mode 0x13 is 320x200 x 8bit, and that the memory buffer is at 0xA0000 - ahhh the memories)

Something like this would work;
C++
#include <stdlib.h>
#include <stdio.h>

void clr() {
    system("cls");
}

int main(int argc, char* argv[]) {
    printf("I won't show up because the screen will be cleared!\r\n");
    clr();
    printf("Hello, world!\r\n");
    return 0;
}


Hope this helps,
Fredrik
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900