Thread: just a quick clear screen question...

  1. #1
    Registered User bobthefish3's Avatar
    Join Date
    Oct 2001
    Posts
    22

    Question just a quick clear screen question...

    i just have a quick ANSI C question. I use MS visual C++ for my C and C++ programs, and i'm wondering if there is any ANSI function (or MS compler) functions to clear a console app screen or to place text in the console app where you would like it in the window (i know back in High school when we used the borland compiler conio.h had a gotoxy function or something like that for putting text where you wanted it)

    If there is any way in MS compilers or ANSI C to do one or both of these tasks, Please let me know, because it would be a very nice effect in my program in currently working on (instead of just scrolling the text infinitely down in the console app window- which is kinda lame).

    If there is a function for it, let me know what header file it is in so i can include it.

    thanx-
    -please do not mess with the incredible radioactive super-fish... thank you.

  2. #2

  3. #3
    Registered User bobthefish3's Avatar
    Join Date
    Oct 2001
    Posts
    22

    kewl, thanx ken-- you da man!

    thanx, I will try that out when i'm off of work and back at my home computer with my compiler.

    Just want to make sure though, is that a function available in ANSI C, or is it compiler-specific, cause for the program i am writing it must be ANSI supported (can't be dependant on the Compiler.

    Now i'm guessing there is no ANSI way to place text on the screen in a certain x,y location in a Console app is there (probably just in a normal win APP - right??)

    anyway, regardless of whether you got the chance to help me out further, i'll definately try it out when i get home again, and thanx again for the help.

    -zeee fish
    -please do not mess with the incredible radioactive super-fish... thank you.

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    35
    backing up KEN's code:

    system("cls");

    to my knowledge, the 'system()' function runs all dos commands. this, therefor is NOT compiler specific. a compiler specific code for borland c is 'clrscr()', but the system() function also works under this compiler because the 'cls' command is available and recognised by all versions of dos.

    if you are compiling on a mac, however, i think the system command is not compatible?.. but as i said, i am not 100% sure that is correct.

    you can run all dos commands through the sytem() function

    hth
    twans

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    197

    Thumbs up

    Code:
    int count;
    for(count=0;count<20;count++, putchar('')) ; /* e.g for 80*20 a screen */
    klausi
    When I close my eyes nobody can see me...

  6. #6
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    system will not be ANSI compliant, because the command you issue to system will be operating system specific and ANSI standard is designed to be OS independent. There is no ANSI way to do what you want. For specific ways please consult the

    FAQ !
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  7. #7
    Registered User bobthefish3's Avatar
    Join Date
    Oct 2001
    Posts
    22

    thanx

    hey all- thanx for the help, i think i'll just go ahead and use the system() function for the project and just make sure i add so much extra genius things in the program that the instructor has no choice but to give a good grade on it (regardless of whether he marks it down for using non-ANSI compliant code)
    Anyway, if there was any sort of curve in the class it would be based around me, so i guess i don't need to worry.

    laterz-
    -please do not mess with the incredible radioactive super-fish... thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Clear Screen Again!!!
    By trang in forum C Programming
    Replies: 3
    Last Post: 12-13-2003, 08:36 AM
  2. Yet another clear screen thread :D
    By kermit in forum Linux Programming
    Replies: 2
    Last Post: 11-20-2003, 05:14 AM
  3. How to clear the screen?
    By Zopyrus in forum C++ Programming
    Replies: 8
    Last Post: 11-07-2003, 10:20 PM
  4. clear screen
    By y2jasontario in forum C Programming
    Replies: 2
    Last Post: 04-04-2002, 12:50 PM
  5. clear screen code, can't get it to work
    By Unregistered in forum C++ Programming
    Replies: 11
    Last Post: 01-25-2002, 01:38 PM