On 8/19/06, alex_merlin_1985 <[EMAIL PROTECTED]> wrote:
> first I want to get done with this, and after that will move to the
> Visual C++...
> well, if you asked the code, the part that refers to my problem is:

You may as well move to Visual C++, since using BGI and Turbo C++ is
*extremely* outdated and non-standard -- you won't be able to move
your code directly, you'll just have to end up rewriting everything.
If you want do use graphics, there are some excellent and *free*
libraries out there (SDL, Allegro, OpenGL, DirectX) that blow the
pants off of BGI. BGI was ok for its time, but is DOS only and quite
obsolete. Not to mention if you are just interested in GUI work, you
get it for free if you are using Windows libraries (or better yet,
using a toolkit like wxWidgets, fltk, GTK+, etc).

> #include <conio.h>
> #include <graphics.h>
>
> void main()

Use int main(). Get used to using int main() because void main() is
not standard, even if some compilers allow it.

> {
>     int gd=DETECT, gm;
>     initgraph(&gd, &gm, "C:\\Borlandc\\Bgi");
>     char key, name1[25];
>     setfillstyle(INTERLEAVE_FILL,LIGHTBLUE);
>     bar(0,0,getmaxx(),getmaxy());
>     outtextxy(100,100,"Type in your name:");
>     /*from here I'm in trouble, if there is a good method to make
> this work, please help me out with the code, and (!) I'd like to
> make it so that the characters are also displayed in graphics mode*/
>     while(key!=13)//enter
>     {
>         key=getch();

Ok, here's one issue... key is only a single character but outtextxy
wants a string.

>         gets(name1);

What happens if I enter 50 characters here? What will be in name1?
Also, where do you use name1? What is its purpose? Like I said before,
gets() is a very dangerous function and while it is still part of the
C run-time library, it should not be used.... ever. Even the Unix man
pages for gets() recommend against its use.

>         outtextxy(200,100,"key");/* <-this line I only put in to see
> if the character I type is captured*/
>     }
>     closegraph();
> }

Since int main() is the Right Way<Tm>, you will need to have return 0;
as the last statement before the closing brace.

-- 
Brett McCoy: Programmer by Day, Guitarist by Night
http://www.alhazred.com
http://www.cassandrasyndrome.com
http://www.revelmoon.com


To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to