2 problems

This is a discussion on 2 problems within the C Programming forums, part of the General Programming Boards category; (1) is there a way tp clear the screen that will work in any compiler. i tried <conio.h> and clrscr() ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    17

    Question 2 problems

    (1)

    is there a way tp clear the screen that will work in any compiler.
    i tried <conio.h> and clrscr() but it does not work in my compiler(microsoft visual 6).

    (2)

    what is the best way of sorting an array of strings in alphabetical order.

    Thanks

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    1) No, but this will work for you with MSVC++ 6
    Code:
    #include <windows.h>
    
    void clrscr()
    {
       COORD coordScreen = { 0, 0 };
       DWORD cCharsWritten;
       CONSOLE_SCREEN_BUFFER_INFO csbi;
       DWORD dwConSize;
       HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    
       GetConsoleScreenBufferInfo(hConsole, &csbi);
       dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
       FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
       GetConsoleScreenBufferInfo(hConsole, &csbi);
       FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
       SetConsoleCursorPosition(hConsole, coordScreen);
    }
    2) It depends on the size of the array and whether or not efficiency is something you want. For most beginning programmers bubble sort is the easiest to work with, but should never be used for any real program. It might be a good idea to work with the qsort function in the standard library, or read up on the different methods of sorting. www.google.com

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 05:35 AM
  3. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 04:48 PM
  4. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 08:19 PM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 03:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21