Thread: Defining my own clear_screen for command app

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    610

    Defining my own clear_screen for command app

    Hello, using Eclipse CDT and MinGW compiler am using my old code which compiled in VS2005 to try compile under this new environment but unsuccessfully ... Here are my files

    Screen.h
    Code:
    #ifndef SCREEN_H
    #define SCREEN_H
    
    #include <windows.h>
    
    namespace screen
    {
    	void clear_screen ();	
    	void user_wait();
    }
    #endif
    Screen.cpp
    Code:
    #include "Screen.h"
    
    #ifndef WIN32
    #include <unistd.h>
    #endif
    
    #ifdef __cplusplus
    #include <iostream>
    #ifndef WIN32
    #include <stdio.h>
    #endif
    using namespace std;
    #else
    #include <stdio.h>
    #endif
    
    void screen::clear_screen ( void )
    {
    	DWORD n;                         /* Number of characters written */
    	DWORD size;                      /* number of visible characters */
    	COORD coord = {0};               /* Top left screen position */
    	CONSOLE_SCREEN_BUFFER_INFO csbi;
    
    	/* Get a handle to the console */
    	HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
    
    	GetConsoleScreenBufferInfo ( h, &csbi );
    
    	/* Find the number of characters to overwrite */
    	size = csbi.dwSize.X * csbi.dwSize.Y;
    
    	/* Overwrite the screen buffer with whitespace */
    	FillConsoleOutputCharacter ( h, TEXT ( ' ' ), size, coord, &n );
    	GetConsoleScreenBufferInfo ( h, &csbi );
    	FillConsoleOutputAttribute ( h, csbi.wAttributes, size, coord, &n );
    
    	/* Reset the cursor to the top left position */
    	SetConsoleCursorPosition ( h, coord );
    }
    
    /*
    note that the function "pause" already exists in <unistd.h>
    so i chose user_wait() for it.
    */
    void screen::user_wait()
    {
    	int c;
    
    	/* eat up characters until a newline or eof */
    	do
    	{
    		c = getchar();
    		if(c == EOF) break;
    	} while(c != '\n');
    }
    i get 'Screen.h: No such file or directory' but its included under header folder in my project, amongst other files not giving same problem.
    Please assist if u can
    Last edited by csonx_p; 01-12-2010 at 11:54 AM.

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Please delete this thread, need to check something first, then will repost correctly.. My apologies

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Defining derivated class problem
    By mikahell in forum C++ Programming
    Replies: 9
    Last Post: 08-22-2007, 02:46 PM
  2. Defining const in a class
    By g4j31a5 in forum C++ Programming
    Replies: 5
    Last Post: 11-20-2006, 11:27 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM