GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Oct-2004, 12:20
enggwaqas enggwaqas is offline
New Member
 
Join Date: May 2004
Posts: 20
enggwaqas is on a distinguished road

printing integers in graphics mode


im unsing turbo c compiler under graphics mode....
is there any way to print intergers at desired coordiates, in graphics mode, except of this, converting int to string using itoa() function (Interger to ASCII) and then print it using gototextxy(), which take some extra memory as it need one int and one string and some extra lines of code.....
Last edited by JdS : 05-Oct-2004 at 07:01. Reason: Please set up signature in your profile only.
  #2  
Old 03-Oct-2004, 13:16
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,242
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by enggwaqas
im unsing turbo c compiler under graphics mode....
is there any way to print intergers at desired coordiates, in graphics mode, except of this, converting int to string using itoa() function (Interger to ASCII) and then print it using gototextxy(), which take some extra memory as it need one int and one string and some extra lines of code.....


Waqas hussain siddiqui
BSCS, KU. 1st Year 2nd Sem.
Chemically Yours~

Look at the cprintf() and gotoxy() functions.
__________________

Age is unimportant -- except in cheese
  #3  
Old 04-Oct-2004, 06:05
enggwaqas enggwaqas is offline
New Member
 
Join Date: May 2004
Posts: 20
enggwaqas is on a distinguished road
Quote:
Originally Posted by WaltP
Look at the cprintf() and gotoxy() functions.
cprintf doesn't work under BGI mode.....i want to print interger under BGI mode as we normally do in default mode e.g. i=10; some_function(x,y,i);
  #4  
Old 04-Oct-2004, 08:12
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,688
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by enggwaqas
cprintf doesn't work under BGI mode.....i want to print interger under BGI mode as we normally do in default mode e.g. i=10; some_function(x,y,i);

It's been years since I have dinked with BGI, and I have no way to test anything that you might come up with, but here's something that comes to mind:

Make your own version of printf() (maybe call it bgiprintf(), or gprintf(), or something). Lets call it gprintf().

gprintf() calls sprintf() to cause your output to go to a string (a locally allocated array of char). Then use outtext() to put the string to the screen. If you haven't used vararg before, read up on it. Some pre-ansi compilers may not support variable number of arguments, but Turbo C that I used "way back when" did.

Regards,

Dave
  #5  
Old 04-Oct-2004, 20:47
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,242
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by enggwaqas
cprintf doesn't work under BGI mode.....i want to print interger under BGI mode as we normally do in default mode e.g. i=10; some_function(x,y,i);
Yep, you're right. I was thinking of text-graphics. This code outputs in BGI mode:
CPP / C++ / C Code:
void DisplayTotals()
{
    char numbuf[6];
    
    setcolor(YELLOW);
    settextstyle(SMALL_FONT, HORIZ_DIR, TextSize+1);
    sprintf(numbuf, "%3d", TotBomb);
    outtextxy(initpoly[0]-TotLocn, initpoly[1], numbuf);
    
    if (DspError)
    {
        sprintf(numbuf, "%3d", TotError);
        outtextxy(initpoly[0]-TotLocn, initpoly[1]+20, numbuf);
    }
}
So it's outtextxy()
__________________

Age is unimportant -- except in cheese
 
 

Recent GIDBlogToyota - 2008 August Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to boot Linux in text mode with GRUB Loader JdS Computer Software Forum - Linux 8 11-Jul-2006 04:41
How to set the control button in the pushed mode? mithila MS Visual C++ / MFC Forum 1 27-Sep-2004 06:32
[Tutorial] Standard I/O aaroncohn C Programming Language 20 27-Feb-2004 21:07
web server in secure mode not connecting to http application tcsasp Apache Web Server Forum 0 06-Nov-2003 00:08

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:50.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.