Problem w/ console application compadibility

This is a discussion on Problem w/ console application compadibility within the C Programming forums, part of the General Programming Boards category; I have been working on a console app for some time now, and it works perfectly in winXp. Yet, the ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    49

    Problem w/ console application compadibility

    I have been working on a console app for some time now, and it works perfectly in winXp. Yet, the problem is that when I took my .exe to school (they use windows98), I was astonished to find that it is kinda wrong in operation here...

    Well ok, all the calculations seem alright, but the problem with when I run my app in win98, my color functions are not showing up right. It is mainly the problem whenever my program calls the color function that makes the background black. In win98, it fails to make the background black. Instead, it uses the same background color I defined before.

    Now what can I do so everything in my console app works perfectly in win98. I am using microsoft visual express 2005 c++. And I am coding in C language.

    Here is some code snippits on my key problems:

    the color functions...

    Code:
    void tdefault()
    {
    	#ifdef WIN32
    		HANDLE hstdo;
    		hstdo = GetStdHandle(STD_OUTPUT_HANDLE);
    		SetConsoleTextAttribute(hstdo, FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    	#endif   
    }


    A menu print function:
    Code:
    void main_menu()
    {
    	tdefault();system("cls");
    	
    	printf("\n\n\n\n\n\n\n\n\t\t\t  ");face_menu_titlebar();
    	printf(" MENU: Main Menu         \n");tdefault();printf("\t\t\t  ");bdefault();
    	printf(" 1. New Campaign         \n");tdefault();printf("\t\t\t  ");bdefault();
    	printf(" 2. Options              \n");tdefault();printf("\t\t\t  ");bdefault();
    	printf(" 3. Exit                 \n");tdefault();printf("\t\t\t  ");bdefault_i();
    	printf(" Type in # corresponding \n");tdefault();printf("\t\t\t  ");bdefault_i();
    	printf(" to desired choice.      \n");tdefault();printf("\t\t\t  ");tdefault();
    
    	char main_menu_select = _getche();
    
    	if(main_menu_select=='1') {difficulty_select();}
    	if(main_menu_select=='2') {menu_options();}
    	if(main_menu_select=='3') {exit();}
    	  else main_menu();
    }
    SCREENSHOT:
    Windows98 prints incorrectly!
    http://img361.imageshack.us/img361/4065/12aj2.jpg

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Windows 98 appears to be filling the remainder of the line with spaces on "\n" as far as I can tell. (And using the current colors.) If you move the "\n"s to after your calls to tdefault();, you'll get the desired results...
    Code:
    printf(" 1. New Campaign         ");tdefault();printf("\n\t\t\t  ");bdefault();
    Also: main_menu() doesn't need to nor should be recursive... a trigger happy user might crash your program by holding down on a wrong key, causing main_menu() to be repeatedly called from itself... simply loop the menu/menu drawing.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    49
    alright, thanx ill give this new way a try at school.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Subject:How to create a C# console application?
    By Adock in forum C# Programming
    Replies: 5
    Last Post: 09-03-2008, 05:58 PM
  2. Console Application
    By llcool_d2006 in forum C++ Programming
    Replies: 11
    Last Post: 11-04-2006, 02:46 PM
  3. problem with console app
    By Jumper in forum Windows Programming
    Replies: 0
    Last Post: 07-03-2004, 04:48 PM
  4. Console Application
    By Mont_Blanc in forum C++ Programming
    Replies: 3
    Last Post: 04-17-2004, 03:07 AM
  5. GUI Application --> Console
    By Student040314 in forum C++ Programming
    Replies: 2
    Last Post: 03-14-2004, 12:30 PM

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