Turbo C/C++ and other junk compilers help, discussions and queries here

Re: Turbo C/C++ graphics distorted

Dude, remove the clrscr() from there and put cleardevice() inplace of it. Also at the end of program call restorecrtmode() after calling closegraph(). That will help i think. And that BGI directory stuff won't matter. I have seen people having two types of installation of TC++, one that contains all the files in the same dir and other which contains files in different subdirectories. Both versions work fine as long as path is set right at all the places. so if you have all the files in, say, c:\tc then specifying c:\\tc in initgraph will work, provided that the driver file egavga.bgi is present in the directory.

I hope this clear things up for everyone. Correct me if i am wrong somewhere :)
 

speedyguy

Cyborg Agent
Re: Turbo C/C++ graphics distorted

@Krazy_About_Technology : placing cleardevice() is not bringing up the output screen...it compiles n remain at editor screen....restorecrtmode is kept aftr closegrph function...

Enjoy~!
 
K

khattam_

Guest
Re: Turbo C/C++ graphics distorted

I used TC Graphics for my Galaxian-Like game for the 1st sem project in C..

This sem (3rd) we decided to code Mario .. no wonder it was barely possible to scroll the screen and load bitmaps and all.. So went for Allegro Gaming Library... It has a manual and examples.. Mario is almost complete...

I suggest u to dump TC graphics and use Allegro..
 

speedyguy

Cyborg Agent
Re: Turbo C/C++ graphics distorted

can u tel me if thrs diff betn allegro, bloodshed n tc as far as coding is concerned...coz i know coding via tc only....

Enjoy~!
 

speedyguy

Cyborg Agent
Re: Turbo C/C++ graphics distorted

hi again,

time has come for me now 2 get in2 graphics for my projects n i still havnt got rid of my issues....plz help me out if thrs an alternative 2 turbo c++ fr graphics...iv tried borland visual but no help as yet...

m posting a proper detail of wat issues m facing wit visuals...plz take a carefull look...

this is on editor windows(turbo c++) wit a dda/bresenham program for linedraw-
*img165.imageshack.us/img165/2174/img1350vq4.th.jpg

this is now into output screen wich is already seen distorted....try 2 read..."enter end points ......... "
*img155.imageshack.us/img155/7357/img1352ac3.th.jpg

this is aftr providing the inputs...u can see d required line but again its distorted at top...it cn b randomly anywhr...
[img=*img403.imageshack.us/img403/2959/img1353wf8.th.jpg]

and now back 2 editor window...eew! can u even see anything....ts all messed up....dunno wat d hecks wrong...
*img165.imageshack.us/img165/8780/img1354xw2.th.jpg

more observations - wen i press alt-enter aftr this 2get 2 windowed screen it gets back 2 normal wit d editor window.....

as soon as i use initgraph....the screen behaves like this.....

my system is (again)-

amd turion64 X2 1gb ddr2,
nVidia geforce go 6150,
hp pavilion tablet pc (tx1000 series)
12" lcd screen...

thanx,

Enjoy~!
 

speedyguy

Cyborg Agent
Re: Turbo C/C++ graphics distorted

hi plz reply if any small idea u have...

thrs one more observation i saw....thr problem is not wit my coding....ts wit my DOS graphics....even other Dos based games r not working in ma system....

Enjoy~!
 

tusharmath

Right off the assembly line
Re: Turbo C/C++ graphics distorted

ive been experiencing d same problem...
ive got d same Geforce 6150
its exactly d same... hve been trin all sorts line drawing/clipping algo's ... none of my graphics programs r wrkin fine... may b its a hardware issue...
hve exams comin closer day by day... nd ders no place to practice

do u hve ny alternative 4 dis?
 

speedyguy

Cyborg Agent
Re: Turbo C/C++ graphics distorted

thrs no issue wit bgi graphics in c++....the graphics in dos is screwed up wit ur system....mine too.....try dos based games even they wont work...

try booting in safe mode wit command prompt n c if it can work wit c++...

else use DosBox Emulator.....that shud work...

Enjoy~!
 

speedyguy

Cyborg Agent
Re: Turbo C/C++ graphics distorted

ya dosbox worked fine...but it reduces executing speed....so not gettin exact idea abt its speed wit other systems...

Enjoy~!
 

garfield_56

zzzzzzzzzz........
Turbo C/C++ and other junk compilers discussions and queries here

hey all,
m learnin c++...i wantd to ask wat is the role og "getch()" in a program.....
i mean most of the programs mentioned in buks nd even on websites don't have a "getch" wriiten before closing main()....but i hv seen dat to get d desired result....i always have to add dis......

why is dis so?? nd is it necessary????
 

Faun

Wahahaha~!
Staff member
Re: getch() in c++

turbo c require getch() and ansi c compilers don't. Find out why ? Just do it and see for yourself
 

garfield_56

zzzzzzzzzz........
Re: getch() in c++

turbo c require getch() and ansi c compilers don't. Find out why ? Just do it and see for yourself



ok...i am using turbo c..((seems like m a total newbie))...

if i may ask...:confused:......y do v use so many diff compilers (borland, ansi, turbo,etc...)???
 

mrintech

Technomancer
Re: getch() in c++

getch() is used for obtaining the desired output

Try removing any of the header file iostream.h and conio.h and see which header file supports getch() ;)
 

garfield_56

zzzzzzzzzz........
Re: getch() in c++

are u sure ?? did u try to see what happens when u dont add getch() to your program ??[/quote]




yup...i did......


wen i 5run d progrm (a normal & simple c++ prog..) a blank screen appears for 2-3 sec nd then it goes bak to my program screen....
 

red_devil

Back!
Re: getch() in c++

^^ so see.. now u know what the use of the getch() is in your program...


anyways, basically, getch is used to single-byte character from the terminal ... so once u add getch, your output screen waits for you to enter a key (which normally is the enter key)
so once u hit enter, the screen is no longer there.

btw, when u dont add getch(), it doesn't mean that your program isn't correct or anything...only your output window doesn't wait for you to take your own time to read all the output that you get...

hope now u've understood what the use of getch() is.

and btw, use system("pause") instead of getch() and check out what happens :D
 

QwertyManiac

Commander in Chief
Re: getch() in c++

This thread was not supposed to have so many posts, damn you T159! It doesn't have anything to do with ANSI/non-ANSI :p

getch - get a single-byte character from the terminal.

When you call getch() (A Windows Platform-only function), it goes into an input event loop and waits for a single character to be entered (and pressed). And it stores that character into a variable, or discards it if you haven't provided one, like in these cases:
Code:
#include <iostream.h>
#include <conio.h>

void main() {
char c;
c = getch(); // Gets and stores a user-input character
cout << c << endl;
cout << "Press any key to exit.";
getch(); // No variable, used to get into an input-event loop.
}

Input-loop as in it goes into a wait-for-user-to-press-a-key mode. You can see it like the behaviour of some applications that say "Press any key to continue...".

garfield_56 said:
wen i 5run d progrm (a normal & simple c++ prog..) a blank screen appears for 2-3 sec nd then it goes bak to my program screen....

When Turbo C runs a program for you, it returns to the editor immediately after the program exits a.k.a the end of main(). So it will appear like your program has started and terminated all of a sudden after your input is given.

As you yourself said, "to get the desired result" which here, is to wait for the user to see the final output, we use a getch(). To give that "Press any key when you have seen the output and exit" effect. Thats all there is to its use in Turbo C programs.

If you ran your compiled program via normal DOS mode, you won't need this feature.

For an example, try running a program without a clrscr() function. You will see the old successful output (upon successive runs), meaning it has nothing to do with the program's working.

garfield_56 said:
if i may ask.........y do v use so many diff compilers (borland, ansi, turbo,etc...)???
You do know compilers are platform-dependent and also architecture-dependent. Code might not be but compilers are. Thus, there came out several multi-featured platform-specific compilers after the C++ language was developed. These specialized compilers like borland aimed to provide good pre-built libraries for programmers to use.

The standard compiler (like ANSI) contains only those functions that can run across all platforms, from OSX to Linux. These specialized compilers come for one specific platform, like Borland for Windows. And they provide Windows-usable special functions, of which things like getch() are a part of.

For learing, using a standard compiler (GNU C Compiler for example) is the best practice, so that what you learn is all things standard (works across all OS) and you won't develop dependence on some particular OS-specific function like getch(). This is but one of the many reasons why people keep recommending them.

Note: Do read my entire post. Not this line alone.
 
Top Bottom