What am i missing?
Code:#include <stdio.h> #include <graphics.h> int main(void){ InitGraphics(0.5, 0.5); Drawline(0.0, 1.0); return 0; }
What am i missing?
Code:#include <stdio.h> #include <graphics.h> int main(void){ InitGraphics(0.5, 0.5); Drawline(0.0, 1.0); return 0; }
Without you telling us which OS / Compiler / graphics library you're using - who the hell knows.
I mean, you didn't even post any error messages.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Grab a pen & paper, put the pen in your hand, make sure the tip is exposed & start moving the tip of the pen on the paper.
Brack, you should be able to get to help on this, by putting your cursor on the word (maybe Drawline() here), and pressing a key combination: f1,and ctrl+f1 are popular choices.
This is how it's done in Turbo C, and some info.
This works in Windows XP.Code:/* line Draws a line between two specified points. Syntax: void far line(int x1, int y1, int x2, int y2); Prototype in: graphics.h Remarks: Draws a line from (x1,y1) to (x2,y2) using the current color, line style, and thickness. It does not update the current position (CP). Return Value: None. Portability: This function is unique to Turbo C++. It works only with IBM PCs and compatibles equipped with supported graphics display adapters. See Also: getlinesettings lineto setlinestyle linerel setcolor setwritemode Example: */ #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xmax, ymax; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } setcolor(getmaxcolor()); xmax = getmaxx(); ymax = getmaxy(); /* draw a diagonal line */ line(0, 0, xmax, ymax); /* draw a rectangle */ line(70, 50, 300, 50); line(300, 50, 300, 150); line(300, 150, 70, 150); line(70, 150, 70, 50); /* clean up */ getch(); closegraph(); return 0; }
thank you salem...
I did not knew that OS/Compiler needed...
i use ubuntu 10.04 LTS. and my programs are written in gedit and compiled with the gcc/g++ command (in terminal).
If there is anything else you want to know please let me know...
oh, i don' t know which library i should use. Actually this is my problem...
Oh, so you can not write a program...only using paper eh? you probably have some more things to learn...Grab a pen & paper, put the pen in your hand, make sure the tip is exposed & start moving the tip of the pen on the paper.
advice: grab a pc and start programing so as sometime you can draw in the screen...Code:Quote: Originally Posted by madmax2006 View Post Grab a pen & paper, put the pen in your hand, make sure the tip is exposed & start moving the tip of the pen on the paper. You forgot 2 important steps: 1) get out of bed in the morning... 2) turn off the computer... Then start using the the pencil and paper.
If I run package manager and type in "graphics", I get over 700 matches.
Care to narrow it down a little?
> oh, i don' t know which library i should use. Actually this is my problem...
So what you're really saying is that you got "unable to find graphics.h include file" ?
Like I said, there are many choices.
But if you're a relative newbie, then perhaps libsdl (look for it in the package manager)
Then visit Simple DirectMedia Layer
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
thank you...i' ll check this out...
#include <stdio.h>
#include <graphics.h>
int main(void){
InitGraphics(0.5, 0.5);
Drawline(0.0, 1.0);
return 0;
}
I dont get any compile time error instead i get a run-time error saying
"BGI error: Graphics not initialized (use initgraph)"
Last edited by nellaikrishna; 10-20-2010 at 10:54 AM.
You didn't load the graphics driver.
See my info and program in this thread, post #5 for how to do it.
and Welcome to the forum, Nellaikrishna!
Another random hijack, with off-topic, unformatted code.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.