Unable to run graphics program in C..

Discussion in 'Programming' started by sauravgr8, Sep 18, 2007.

Thread Status:
Not open for further replies.
  1. sauravgr8

    sauravgr8 New Member

    Joined:
    Jun 21, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    I am unable to run even a simplest graphics program in C, even though when i compile the program it shows success but when i run it , it gives the error that the
    BGI error: graphics not initialized...
    I dont know where is the problem...can any one help plz
    #include<stdio.h>
    #include<conio.h>
    #include<graphics.h.
    void main()
    {
    int gd=DETECT,GM;
    initgraph(&gd,&gm,"");
    setbkcolor(RED);
    getch();
    }
     
  2. fun2sh

    fun2sh Pawned!... Beyond GODLIKE

    Joined:
    May 2, 2006
    Messages:
    1,062
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    World Of Warcraft -DOTA
    wrong section mate. should be in question n ans section

    wat compiler r u using
     
  3. aditya.shevade

    aditya.shevade Console Junkie

    Joined:
    Jun 29, 2006
    Messages:
    990
    Likes Received:
    3
    Trophy Points:
    0
    Location:
    USA
    If the programs compiles with graphics.h included, I think it's Borland compiler.
     
  4. OP
    sauravgr8

    sauravgr8 New Member

    Joined:
    Jun 21, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    ^^^^
    yah its borland compiler, well , now can u suggest me any clue, why its not running...
     
  5. Ron

    Ron ||uLtiMaTE WinNER||

    Joined:
    Nov 12, 2006
    Messages:
    704
    Likes Received:
    6
    Trophy Points:
    0
    Location:
    Kathmandu,Nepal
  6. adi007

    adi007 New Member

    Joined:
    Sep 10, 2007
    Messages:
    713
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    hassan
    try giving .cpp extension to the filename and compile it.
     
    Last edited: Sep 19, 2007
  7. saurabh kakkar

    saurabh kakkar D i s t i n c t l y Ahead

    Joined:
    Sep 1, 2006
    Messages:
    495
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New delhi
    Do this :

    ENABLE GRAPHICS BY GOING TO OPTIONS MENU IN TC COMPILER THEN CLICK LINKERS THEN CLICKING [ ]GRAPHICS LIBRARY .DO NOT CHANGE ANY OTHER OPTION.

    hope this will help :)

    and plz post ur Questions in QnA section
     
  8. OP
    sauravgr8

    sauravgr8 New Member

    Joined:
    Jun 21, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0

    I am already using CPP extension , even though its not working:(

    I tried doing this friend, i left rest of the option as intact, and just removed the cross from graphics library as u said, but still the problem persists:-?
     
    Last edited: Sep 20, 2007
  9. saurabh kakkar

    saurabh kakkar D i s t i n c t l y Ahead

    Joined:
    Sep 1, 2006
    Messages:
    495
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New delhi
    are sorry dont remove the cross instead run this program :

    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<graphics.h>
    void main()
    {
    int gd=DETECT,gm;
    initgraph(&gd,&gm,"c:\\tc\\bgi");
    setbkcolor(RED);
    getch();
    }
    
    Problems in ur program

    #include<stdio.h>
    #include<conio.h>
    #include<graphics.h.<----------should be #include<graphics.h>
    void main()
    {
    int gd=DETECT,GM;<-----------should be gm i.e in small
    initgraph(&gd,&gm,"");
    setbkcolor(RED);
    getch();
    }

    hope this will help
     
  10. gofeddy

    gofeddy New Member

    Joined:
    Nov 22, 2006
    Messages:
    60
    Likes Received:
    0
    Trophy Points:
    0
    replace this line wit.......initgraph(&gd,&gm,"..\\bgi");

    it might work
     
  11. Faun

    Faun Wahahaha~! Staff Member

    Joined:
    Dec 8, 2006
    Messages:
    9,912
    Likes Received:
    27
    Trophy Points:
    48
    Location:
    Pune/there
    Search turbo c/c++ help before drawing out conclusion.

    U could hav find the answers if u hav right clicked on graphics.h, then would hav scrolled right to the bottom to see some examples, copy the driver initiaiization part from any of the exaples and give the address of bgi directory. e.g. if ur tc is in c: drive then give
    c:\\tc\\bgi
    as the path
     
  12. The_Devil_Himself

    The_Devil_Himself die blizzard die! D3?

    Joined:
    Aug 5, 2007
    Messages:
    2,330
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Event horizon
    +1.This worked fr me.
     
  13. Faun

    Faun Wahahaha~! Staff Member

    Joined:
    Dec 8, 2006
    Messages:
    9,912
    Likes Received:
    27
    Trophy Points:
    48
    Location:
    Pune/there
    just for info
    . is for parent dir
    .. is the present working dir
     
  14. OP
    sauravgr8

    sauravgr8 New Member

    Joined:
    Jun 21, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0



    Sorry , it was just a typing mistake here, but in the borland C i did the way u said ...but still it was not working , i tried all the remedies, even gave the path within that inverted commas, but still its not working...what should i do know...
     
  15. saurabh kakkar

    saurabh kakkar D i s t i n c t l y Ahead

    Joined:
    Sep 1, 2006
    Messages:
    495
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New delhi
    there is no problem in My program i have executed it in TURBO C++

    all i can suggest to is to Dump Borland compiler and use TURBO C++ :D

    if u r not able to find TURBO C++ i can upload it for u :)
     
  16. aditya.shevade

    aditya.shevade Console Junkie

    Joined:
    Jun 29, 2006
    Messages:
    990
    Likes Received:
    3
    Trophy Points:
    0
    Location:
    USA
    ^^ Oi... Turbo C/C++ is an IDE (Integrated Development Environment) that uses Borland's C/C++ compiler.
     
  17. saurabh kakkar

    saurabh kakkar D i s t i n c t l y Ahead

    Joined:
    Sep 1, 2006
    Messages:
    495
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New delhi
    thanks man for the info i was confused i was also thinking that both r same

    thing :)

    @ sauravgr8 : plz provide the error that u r getting
     
  18. OP
    sauravgr8

    sauravgr8 New Member

    Joined:
    Jun 21, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    #include<stdio.h>
    #include<conio.h>
    #include<graphics.h>
    void main()
    {
    int gd=DETECT,gm;
    initgraph(&gd,&gm,"C:/TC/BIN");
    setbkcolor(RED);
    getch();
    }
    this is the program i typed in and saved with .c extension
    now when i compile it shows success
    but wheni i run it gives an error
    UNABLE TO OPEN " TCCLASS.LIB"
    now what should i do
     
  19. saurabh kakkar

    saurabh kakkar D i s t i n c t l y Ahead

    Joined:
    Sep 1, 2006
    Messages:
    495
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New delhi
    ^^ I have uploaded my Tc compiler extract it using winrar and then install :) By clicking on

    INSTALL.EXE then chose the location where u want ur Tc folder then press y on each Q asked

    then When done !! comes instalation is complete

    then ENABLE GRAPHICS BY GOING TO OPTIONS MENU IN TC COMPILER THEN CLICK LINKERS THEN

    CLICKING [X]GRAPHICS LIBRARY . do not remove the [X] if it already exists :D

    File: C++.rar

    DownloadLink: http://rapidshare.com/files/57529675/C__.rar

    then run ur Program this time it shud Run :)
     
    Last edited: Sep 23, 2007
Thread Status:
Not open for further replies.

Share This Page