Hi there ! How r u?

Ohh I really need your help great programmers ...
I am new for programming and I am trying to do things by myself but here I need your help :-|

I would like to draw something in C or C++ but I got no basic IDEA ...
For example any kinds of graphics I would like to draw but...
I searched internet but I couldn't find concrete answer please give me some data link where can I learn or give me some advise of yours please please ... :sad:

give me some examples how can I use graphics.h lib .

I tried to draw "sine wave" but I couldn't please help me with this ...

Thanks beforehand.... ;)

Recommended Answers

All 18 Replies

graphics.h is a very old library for doing graphics in DOS with Borland C++ 3.x.
It's not supported under Windows, and the compiler isn't supported either.

Sorry may be I made my question not clear....

I just tried to draw y=sin(x) function graph just or something like that y=x+1 or e.t.c.

can you give me some hints for beginning my programm...

for example:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include "graphics.h"

#define ESC 0x1b

void main () {

srand(time(NULL));

int GraphDriver=0; GraphMode=0;

initgraph (&GraphDriver ,&GraphMode, "", 640,480);

char tempstring[80];

getch() ;

}

}

Please do help me with drawing this y = sin(x) graph......

Do forgive me If I make some misunderstanding ....
Thanks

There is a C++ code snippet right here on DaniWeb called "Add a little Graphics to your Console" at:
http://www.daniweb.com/code/snippet173.html

You could potentially draw short lines following the x,y coordinates of your sin(x) function.

Forget about the old graphics.h and Borland BGI DOS stuff, that was left in the 16 bit graveyard a long time ago!

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include "graphics.h"

#define ESC 0x1b

void main () {

srand(time(NULL));

int GraphDriver=0; GraphMode=0;

initgraph (&GraphDriver ,&GraphMode, "", 640,480);

char tempstring[80];

getch() ;

}

}

Spotted a few errors (although i accept it is work in progress :) ): main should be declared as int main NOT void main....
...GraphMode is undefined as the previous ; finishes the statement (change the previous ; to a , ) and also ESC and tempstring are not used! also do you not have to shut down the driver at the end? - and bear in mind main returns 0; :p

Thanks for suggestion but you know I hardly understand that code and here I am going to show you the code which I began first here and this is only drawing of X and Y oxes and I have to go on drawing sin(x) function please give me your suggestion....

#include "stdafx.h"
#include <graphics.h>
#include <conio.h>


void main()
{


int gd=DETECT, gm;
initgraph(&gd,&gm,"");


int x,y, j=250 ;


setbkcolor(WHITE);
setcolor(LIGHTBLUE);


outtextxy(3,5," I am so stupid hyong I am so stupid sorry sorry !!! "); // output "line" text



x = getmaxx();
y = getmaxy();


x=j;


line(j,0,x,y);


x = getmaxx();
y = getmaxy();


y=j;


line(0,j,x,y);



/*void line(int x0, int y0, int x1, int y1)


{
POINT line[2];
line[0].x = x0;
line[0].y = y0;
line[1].x = x1;
line[1].y = y1;
drawpoly(2, (int*)&line);
}
*/



getch();


closegraph(); // escape graphic mode
}

Thanks very much ....

    #include "stdafx.h"
    #include <graphics.h>
    #include <conio.h>

    void main()
    {
            int gd=DETECT, gm;
            initgraph(&gd,&gm,"");

            int x,y, j=250 ;

            setbkcolor(WHITE);
            setcolor(LIGHTBLUE);

         outtextxy(3,5," I am so stupid hyong I am so stupid sorry sorry !!! ");    // output "line" text

         x = getmaxx();
            y = getmaxy();

              x=j;     

               line(j,0,x,y);

               x = getmaxx();
            y = getmaxy();

              y=j;     

               line(0,j,x,y);
                    /*void line(int x0, int y0, int x1, int y1)

    {
        POINT line[2];
        line[0].x = x0;
        line[0].y = y0;
        line[1].x = x1;
        line[1].y = y1;
        drawpoly(2, (int*)&line);
    }
     */ 

           getch();

            closegraph(); // escape graphic mode
    }

Thanks very much ....

Jwenting says:
"graphics.h is a very old library for doing graphics in DOS with Borland C++ 3.x.
It's not supported under Windows, and the compiler isn't supported either."

I guess you are using Microsoft VC++...

1000BhP says:
"main should be declared as int main NOT void main...."

I don't think you have read their posts...

O.K ...O.K...O.K... :

Yes you are right I am using Microsoft VC++

Thanks much ...

NOw I c my mistakes thanks ...

NOw I am going to correct my mistakes

Thanks ....

Is there any way to graphics in windows. Plz not open gl. Its too difficult. Something as simple and easy as bgi graphics.

>>Is there any way to graphics in windows
Learn Windows API.

I want to do graphics in console type apps. What should I use?

I want to do graphics in console type apps. What should I use?

Please try this link

Please try this link

free_eagle thanks for the link!!!!
I modified the package slightly, and was able to use it with Dev_C++
It works like a charm! I left a little code snippet on DaniWeb showing the details.

thanks again, team work at its best ...

free_eagle thanks for the link!!!!
I modified the package slightly, and was able to use it with Dev_C++
It works like a charm! I left a little code snippet on DaniWeb showing the details.

thanks again, team work at its best ...

YOu are welcome :surprised

I am very glad that I could do some useful thing here , even though I am very new in this kind of matters ...

I have been learning programming for three weeks...
Acctually I am majoring medecine so before I didn't have to study these programming languages ...

As nowadays I got 2 month vacation I decided to learn some programming language :cool:

AND Thanks to this Forum I am learning much things thanks to you very much members of this forum for your help ... :cool:

I hope you enjoy your adventures into the world of programming. The logic you learn will help your brain to think better. You are very welcome to ask questions on this forum, most of us are pretty friendly.

Give us enough detail to answer the question. Don't worry too much about the English, it's not my mother language either and I manage to get by.

I hope you enjoy your adventures into the world of programming. The logic you learn will help your brain to think better. You are very welcome to ask questions on this forum, most of us are pretty friendly.

Give us enough detail to answer the question. Don't worry too much about the English, it's not my mother language either and I manage to get by.

Thanks very much for welcoming :!:

As the rule of this Forum first I have to make my effort to deserve your help.

Thanks much .... ^_^

Hi there ! How r u?

Ohh I really need your help great programmers ...
I am new for programming and I am trying to do things by myself but here I need your help :-|

I would like to draw something in C or C++ but I got no basic IDEA ...
For example any kinds of graphics I would like to draw but...
I searched internet but I couldn't find concrete answer please give me some data link where can I learn or give me some advise of yours please please ... :sad:

give me some examples how can I use graphics.h lib .

I tried to draw "sine wave" but I couldn't please help me with this ...

Thanks beforehand.... ;)

im renn can you help some graphics program to do coz 8s my big project in 1st. college pls reply hope u will read and appreciate this comment.

im renn can you help some graphics program to do coz 8s my big project in 1st. college pls reply hope u will read and appreciate this comment.

Do not reply to old threads if you not gone post solution. If you need help with your project create new thread, well explain in full sentence English and of course do not forget include relevant coding.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.