GIDForums

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-May-2007, 15:05
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road
Smile

Linked Lists advice request


Hullo,

(I thought I'd start a new thread, so as to be tidier, and not appear to be begging.)

This is a programme for drawing shapes and rotating them, moving them about, changing their size with cursor keys; I need to use linked lists to store the data for the shapes.

I've only got 1 error in my code when I compile it:
summat like this:
Quote:
--------------------Configuration: shapeshifter - Win32 Debug--------------------
Compiling...
shapeshifter.c
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(28 ) : fatal error C1083: Cannot open include file: 'graphics_lib.h': No such file or directory
Error executing cl.exe.

shapeshifter.exe - 1 error(s), 0 warning(s)


I've got "graphics_lib.h" in the following files:
"C:\Documents and Settings\...\shapeshifter\shapeshifter\graphics_li b\HERE"
"C:\Documents and Settings\...\shapeshifter\shapeshifter\HERE"
"C:\Documents and Settings\...\shapeshifter\graphics_lib\& HERE"

I've added it to the project and stuck it into the header file on the folder tree in the top left o' screen (I'm using MS Visual C++ 6 btw)

and I get the same error message.

Please could somebody help?

Tidier (but still far from fixed) Code:
CPP / C++ / C Code:
/*
 * Shapeshifter (a vector graphics drawing programme by me)
 */

/*
 * Passing by reference
 */
typedef struct long_line_type //this is my structure "long_line_type" and contains the following bits of info:
{
    int start_x1, start_y1;
    int start_x2, start_y2;
    int start_x3, start_y3;
    int colour;
} shape;
// this is a nickname for the structure "long_line_type" this shape is passing these variables

/*
typedef struct {int x, y, z;} Point;    // exclude z for 2D
// a Triangle is given by three points: Point V0, V1, V2
*/
/*
 * Display a single line
 */

#include <stdio.h>
#include <graphics_lib.h>
#include <math.h>
#include <conio.h>

//First define "this_line" as a pointer.
void display_line(line_type *this_line) //"display_line" = "draw_line"
{

 /* Open a graphics window */
 //initwindow(800, 600);
 /* Set the colour */
 setcolor(this_line->colour); //to set colour of line. the arrow dereferernces the *

 /* Draw the line
 line(this_line->start_x,this_line->start_y,this_line->end_x,this_line->end_y); //to set a co-ord to draw line
}
void get_line(line_type *line_pointer)        //line is a pointer to a line type
{

 //accessing the members of the "structure" (a collection of differnet variables like it's 1.2,1.2,1.3 etc but with words

//"line" is the actual name of the varaible

 //user the (). notation when you haven't got a pointer variable; use the arrow notation when you have got a pointer variable - this is to get the user input fot the centre point
scanf("%d", &line_pointer->start_x0);
scanf("%d", &line_pointer->start_y0);
scanf("%d", &line_pointer->colour);

}

//can't return anything

//I have stored the address &line in the pointer called "line_pointer"; line_pointer contains all the address of the 5 scanf bits above.

//line_pointer is a "postcode" (pointer) that sends data to the "house" (structure) called "line"

//passing by reference

 /*
 * THE MAIN FUNCTION - the programme starts executing here
 */
int main(void)
{

 /* DECLARE VARIABLES */

    /* Display the lines */

    //calling the function: "line" is a local variable; "display_line" is the type of variable to be called
 display_line(&line);
 
 /* Title Screen Function */

          /* Open a graphics window */
  initwindow(800, 600);

     printf("SHAPESHIFTER a shape drawing programme by Jack McNeill");
     printf("Press space bar to continue");
     getch();

     /* Instruction Screen Function */
     printf("1. blah blah blah; 2. blah blah blah; 3. blah blah blah; 4. blah blah blah; 5. blah blah blah; 6. blah blah blah");
     printf("Press space bar to continue");
     getch();

     /* Size Selection Function */
              printf("please la de dah... ");
              scanf("%d",&size); 

/*this is to move the current point up and down to search fr data.. this is the linked list bit for findig data*/
#include <stdlib.h>   //<<---- this too
#include <string.h>   //<<---- this too      

struct llist {
 char *str;
 struct llist *next;   //a pointer to the next element
}shape;
 
//structure name 
int main(void) { //<<----- watch it!!!
 char line[1024];
 struct llist *head = NULL;   //a pointer to the first element in the list
 struct llist *new = NULL;

 while(fgets(line, 1024, stdin) != NULL)
 {
  new = (struct llist *)malloc(sizeof(struct llist));
  new->next = head;
  head = new;
  new->str = strdup(line);
 }

 while(head != NULL)
 {
  printf("%s\n", head->str);
  head = head->next;
 }

  //http://www.cs.ccsu.edu/~markov/ccsu_courses/161Syllabus.html#CS161%20-%20C%20programming,%20Lecture%209

  // Allocating storage for list elements

struct list *newelement() //creates an instance of the list structure
{
   return (struct list *)malloc(sizeof(struct list));
}

// Adding list elements
/*
void push(int val)
{
struct list *q;          /* add an element in the beginning of the list
  q=newelement();     /* create new element
  (*q).val=val;       /* assign the value member
  (*q).next=p;        /* set the pointer to the next element
  p=q;                /* set the global list pointer
}

void append(int val)
{           
  struct list *q, *t;            /* add an element at the end of the list
  q=newelement();
  (*q).val=val;                   /* alternative notation: q->val=val
  (*q).next=NULL;
  if (p==NULL)                   /* the list is empty
  p=q;

     else
     {                           /* the list is not empty
     t=p;
     while ((*t).next!=NULL)   /* move t at the and of the list
     t=(*t).next;
     (*t).next=q;              /* connect the new element
     }

}

 /* Reading and printing lists

void main()
{
  struct list *q;
  int x;
  p=NULL;    /* initialize the list - empty list
 
  do
  {      /* read numbers and store them in a list
    scanf("%d",&x);
    if (x>0) append(x); /* push(x) stores the list in reverse order
  }

  while (x>0);  /* x<=0 end of input
  q=p;
 
  while (q!=NULL)
  {   /* print the list
    printf("%d\n",(*q).val);
    q=(*q).next;
  }

}

*/

// p=point; np=new point - changed to "start_x" etc...

scanf("%d",&degree);

              sin_value = sin (degree*PI/180);
              cos_value = cos (degree*PI/180);

              start_x1.x=(((p1.x*cos_value )-(p1.y*sin_value)));
              start_y1.y=(((p1.y*cos_value )+(p1.x*sin_value)));
              start_x 2.x=(((p2.x*cos_value)-(p2.y*sin_value)));
              start_y2.y =((( p2.y*cos_value)+(p2.x*sin_value)));
              start_x3 .x=(((p3.x*cos_value )-(p3.y*sin_value)));
              start_y3.y =(((p3.y*cos_value)+(p3.x*sin_value )));
              told(p1,p2,p3,0);
              new_triangle(shape,3,1);
              copyvalue();
 
     new_x = cos(theta) * x - sin(theta) * y;
     new_y = sin(theta) * x + cos(theta) * y;

 getch();

 closegraph();

 return 0;

}


I've "//"-ed out a lot of the line stuff so I can focus on the triangle (esp the rotation)... where to shove this poxy graphics_lib.h file to get it compiling?!

Please could someone help?!
Last edited by LuciWiz : 15-May-2007 at 05:04. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 14-May-2007, 15:29
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,520
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Linked Lists advice request


Quote:
Originally Posted by promsan
CPP / C++ / C Code:

#include <graphics_lib.h>


Try the following:

Put graphics_lib.h in the same directory as the .c or .cpp file that includes it, then change the above line to
CPP / C++ / C Code:
#include "graphics_lib.h"
Regards,

Dave
  #3  
Old 14-May-2007, 17:11
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road
Question

Re: Linked Lists advice request


Hi Dave,

Thanks for your help, it's much appreciated!

Did as you said (I think!)

This is what I got:
Quote:
--------------------Configuration: shapeshifter - Win32 Debug--------------------
Compiling...
shapeshifter.c
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(31) : error C2143: syntax error : missing ')' before '*'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(31) : error C2143: syntax error : missing '{' before '*'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(31) : error C2059: syntax error : ')'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(32) : error C2054: expected '(' to follow 'this_line'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(217) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

shapeshifter.obj - 5 error(s), 0 warning(s)


A friend of mine offered these thoughts... what do you think?
Quote:
the error might be caused by the location of the file.
this has two possible solutions.
one is to check where the file is. it should be in the directory where you have built the program.
The other is to check the path(^^) of the file, in order to compile with the file.
open the program, and then press the setting menu, and click the link tab
finally you will see the category menu. check input part.
in the part, the file should be defined.... if not, you can type the file name in there...
  #4  
Old 14-May-2007, 17:34
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,520
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Linked Lists advice request


Quote:
Originally Posted by promsan
Hi Dave,

Thanks for your help, it's much appreciated!

Did as you said (I think!)
what do you think?

I think you should check the header file. (Since you are getting different errors, I am assuming that it is now finding the header that it couldn't see before. That's where the problem lies, I'm thinking.)

When you include a file, and you have errors immediately after the #include statement, then look at what you included.
Can you post it (the .h file)?

Show the part of the file that includes it (mark for us whatever line that is flagged by the error message) and show us the .h file.

Regards,

Dave
  #5  
Old 14-May-2007, 18:09
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road

Re: Linked Lists advice request


The Graphics_lib.h is
Code:
// FILE: winbgim.h // WINBGIM Version 3.4 -- Dec 21, 1999 // modified to run under Borland C++ 5.02 for Windows OR under the // mingw32 g++ compiler for Windows. There are also some additions // for mouse control and RGB colors. Documentation on how to use these // functions is available in www.cs.colorado.edu/~main/bgi/docs/ // // Modification log by Michael Main: // --Version 2.1: Oct 17, 1998 // Some mouse additions to Konstantin's original code // --Version 2.2: November 1, 1998 // Modified getch so that it can get the arrows and other keypad keys. // --Version 2.3: November 17, 1998 // Fixed a bug in getpixel. // --Version 2.4: November 25, 1998 // Added functions getactivepage() and getvisualpage() to get the current // page number of the active and visual pages. In this implementation, the // MAX_PAGES is set to 16, but I have used only pages 0 and 1 myself. // --Version 3.1: June 17, 1999 // Mostly implemented by Mark Richardson: // Implements getimage and putimage. // Adds new support for rgb colors. // --Version 3.2: June 21, 1999 // Made modifications so that everything works with the mingw32 // G++ compiler for Windows. Details for installing and using this // free compiler are in www.cs.colorado.edu/~main/mingw32/README.html // --Version 3.3: Oct 4, 1999 // Added ismouseclick and getmouseclick // --Version 3.4: Dec 21, 1999 // Added clearmouseclick. // Fixed bug causing getmouseclick to fail when x and y are same variable. // Fixed bug in setcolor that sometimes caused the fill color to change // to the drawing color. #ifndef __GRAPHICS_H__ #define __GRAPHICS_H__ #define far #define huge #include <stddef.h> #include <conio.h> #include <windows.h> // added by PJK #ifndef __COLORS #define __COLORS enum colors { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE }; #endif /** Some different definitions for the Mingw32 g++ compiler and * the Borland 5.0 compiler. Added by Michael Main, June 21, 1999. * Michael Main -- 10/17/98 */ #if defined(_WINDOWS_H) || defined(_GNU_H_WINDOWS_H) /* MINGW32 G++ Compiler: * Define the colors type in the same way that Borland does. * Define CLR_INVALID from Borlands /win32/wingdi.h. * Get the memset prototype from string.h. Note that sometimes <string.h> is * actually <g++/String.h> for the Windows compiler because. In this case * _STRING_H_ will not be defined but we can still pick it up from <../string.h>. * Also define random for the bgidemo function. */ enum colors { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE }; #if !defined(CLR_INVALID) #define CLR_INVALID 0xFFFFFFFF #endif #include <string.h> #ifndef _STRING_H_ #include <../string.h> #endif #else /* BORLAND Compiler: * Colors are already defined in the BC5 conio.h, using COLORS. * So for Borland I'll replace this enum with a #define definition. */ //#define colors COLORS #endif #ifndef random #define random(range) (rand() % (range)) #endif // A definition to fix a misspelling of MAGENTA throughout this file: #define MAGENT MAGENTA enum write_modes { COPY_PUT, XOR_PUT, OR_PUT, AND_PUT, NOT_PUT }; enum line_styles { SOLID_LINE, DOTTED_LINE, CENTER_LINE, DASHED_LINE, USERBIT_LINE }; enum fill_styles { EMPTY_FILL, SOLID_FILL, LINE_FILL, LTSLASH_FILL, SLASH_FILL, BKSLASH_FILL, LTBKSLASH_FILL, HATCH_FILL, XHATCH_FILL, INTERLEAVE_FILL, WIDE_DOT_FILL, CLOSE_DOT_FILL, USER_FILL }; enum text_directions { HORIZ_DIR, VERT_DIR }; enum font_types { DEFAULT_FONT, TRIPLEX_FONT, SMALL_FONT, SANSSERIF_FONT, GOTHIC_FONT }; #define LEFT_TEXT 0 #define CENTER_TEXT 1 #define RIGHT_TEXT 2 #define BOTTOM_TEXT 0 #define TOP_TEXT 2 #define NORM_WIDTH 1 #define THICK_WIDTH 3 #define DOTTEDLINE_LENGTH 2 #define CENTRELINE_LENGTH 4 #define USER_CHAR_SIZE 0 #define MAXCOLORS 15 #define CLIP_ON 1 #define CLIP_OFF 0 #define TOP_ON 1 #define TOP_OFF 0 // Definitions for the key pad extended keys are added here. I have also // modified getch() so that when one of these keys are pressed, getch will // return a zero followed by one of these values. This is the same way // that it works in conio for dos applications. // M. Main -- Nov 3, 1998 #define KEY_HOME 71 #define KEY_UP 72 #define KEY_PGUP 73 #define KEY_LEFT 75 #define KEY_CENTER 76 #define KEY_RIGHT 77 #define KEY_END 79 #define KEY_DOWN 80 #define KEY_PGDN 81 #define KEY_INSERT 82 #define KEY_DELETE 83 #define KEY_F1 59 #define KEY_F2 60 #define KEY_F3 61 #define KEY_F4 62 #define KEY_F5 63 #define KEY_F6 64 #define KEY_F7 65 #define KEY_F8 66 #define KEY_F9 67 enum graphics_errors { grOk = 0, grNoInitGraph = -1, grNotDetected = -2, grFileNotFound = -3, grInvalidDriver = -4, grNoLoadMem = -5, grNoScanMem = -6, grNoFloodMem = -7, grFontNotFound = -8, grNoFontMem = -9, grInvalidMode = -10, grError = -11, grIOerror = -12, grInvalidFont = -13, grInvalidFontNum = -14, grInvalidDeviceNum = -15, grInvalidVersion = -18 }; /* Graphics drivers constants, includes X11 which is particular to XBGI. */ #define DETECT 0 #define CGA 1 #define MCGA 2 #define EGA 3 #define EGA64 4 #define EGAMONO 5 #define IBM8514 6 #define HERCMONO 7 #define ATT400 8 #define VGA 9 #define PC3270 10 /* Graphics modes constants. */ #define CGAC0 0 #define CGAC1 1 #define CGAC2 2 #define CGAC3 3 #define CGAHI 4 #define MCGAC0 0 #define MCGAC1 1 #define MCGAC2 2 #define MCGAC3 3 #define MCGAMED 4 #define MCGAHI 5 #define EGALO 0 #define EGAHI 1 #define EGA64LO 0 #define EGA64HI 1 #define EGAMONOHI 3 #define HERCMONOHI 0 #define ATT400C0 0 #define ATT400C1 1 #define ATT400C2 2 #define ATT400C3 3 #define ATT400MED 4 #define ATT400HI 5 #define VGALO 0 #define VGAMED 1 #define VGAHI 2 #define VGAMAX 3 #define PC3270HI 0 #define IBM8514LO 0 #define IBM8514HI 1 typedef struct arccoordstype { int x; int y; int xstart; int ystart; int xend; int yend; } arccoordstype; typedef char fillpatterntype[8]; typedef struct fillsettingstype { int pattern; int color; } fillsettingstype; typedef struct linesettingstype { int linestyle; unsigned int upattern; int thickness; } linesettingstype; typedef struct palettetype { unsigned char size; signed char colors[16]; } palettetype; typedef struct textsettingstype { int font; int direction; int charsize; int horiz; int vert; } textsettingstype; typedef struct viewporttype { int left; int top; int right; int bottom; int clip; } viewporttype; // This struct was moved here to allow access to the struct (Mark Richardson 11/29/98) struct BGIimage { short width; // 2 bytes short height; // 2 bytes Note:This means bits is also aligned to 32bit(DWORD) boundry char bits[1]; }; #ifndef NOT_USE_PROTOTYPES #define PROTO(ARGS) ARGS #else #define PROTO(ARGS) () #endif #if defined(__cplusplus) extern "C" { #endif // // Setting this variable to 0 increase speed of drawing but // correct redraw is not possible. By default this variable is initialized by 1 // extern int bgiemu_handle_redraw; // // Default mode choosed by WinBGI if DETECT value is specified for // device parameter of initgraoh(). Default value is VGAMAX which // cause creation of maximized window (resolution depends on display mode) // extern int bgiemu_default_mode; void _graphfreemem PROTO((void *ptr, unsigned int size)); void* _graphgetmem PROTO((unsigned int size)); void arc PROTO((int, int, int, int, int)); void bar PROTO((int, int, int, int)); void bar3d PROTO((int, int, int, int, int, int)); void circle PROTO((int, int, int)); void cleardevice PROTO((void)); void clearviewport PROTO((void)); void closegraph PROTO((void)); void detectgraph PROTO((int *, int *)); void drawpoly PROTO((int, int *)); void ellipse PROTO((int, int, int, int, int, int)); void fillellipse PROTO((int, int, int, int)); void fillpoly PROTO((int, int *)); void floodfill PROTO((int, int, int)); void getarccoords PROTO((arccoordstype *)); void getaspectratio PROTO((int *, int *)); int getbkcolor PROTO((void)); int getcolor PROTO((void)); palettetype* getdefaultpalette PROTO((void)); char* getdrivername PROTO((void)); void getfillpattern PROTO((char const *)); void getfillsettings PROTO((fillsettingstype *)); int getgraphmode PROTO((void)); void getimage PROTO((int, int, int, int, void *)); void getlinesettings PROTO((linesettingstype *)); int getmaxcolor PROTO((void)); int getmaxmode PROTO((void)); int getmaxx PROTO((void)); int getmaxy PROTO((void)); char* getmodename PROTO((int)); void getmoderange PROTO((int, int *, int *)); void getpalette PROTO((palettetype *)); int getpalettesize PROTO((void)); unsigned int getpixel PROTO((int, int)); void gettextsettings PROTO((textsettingstype *)); void getviewsettings PROTO((viewporttype *)); int getx PROTO((void)); int gety PROTO((void)); void graphdefaults PROTO((void)); char* grapherrormsg PROTO((int)); int graphresult PROTO((void)); unsigned int imagesize PROTO((int, int, int, int)); void initgraph PROTO((int *, int *, char const *)); int installuserdriver PROTO((char const *, int *)); int installuserfont PROTO((char const *)); void line PROTO((int, int, int, int)); void linerel PROTO((int, int)); void lineto PROTO((int, int)); void moverel PROTO((int, int)); void moveto PROTO((int, int)); void outtext PROTO((char const *)); void outtextxy PROTO((int, int, char const *)); void pieslice PROTO((int, int, int, int, int)); void putimage PROTO((int, int, void *, int)); void putpixel PROTO((int, int, int)); void rectangle PROTO((int, int, int, int)); int registerbgidriver PROTO((void *)); int registerbgifont PROTO((void *)); void restorecrtmode PROTO((void)); void sector PROTO((int, int, int, int, int, int)); void setactivepage PROTO((int)); void setallpalette PROTO((palettetype *)); void setaspectratio PROTO((int, int)); void setbkcolor PROTO((int)); void setcolor PROTO((int)); void setfillpattern PROTO((char const *, int)); void setfillstyle PROTO((int, int)); unsigned int setgraphbufsize PROTO((unsigned int)); void setgraphmode PROTO((int)); void setlinestyle PROTO((int, unsigned int, int)); void setpalette PROTO((int, int)); void setrgbpalette PROTO((int, int, int, int)); void settextjustify PROTO((int, int)); void settextstyle PROTO((int, int, int)); void setusercharsize PROTO((int, int, int, int)); void setviewport PROTO((int, int, int, int, int)); void setvisualpage PROTO((int)); void setwritemode PROTO((int)); int textheight PROTO((char const *)); int textwidth PROTO((char const *)); int getch PROTO((void)); int kbhit PROTO((void)); void delay PROTO((unsigned msec)); void restorecrtmode PROTO((void)); /* Additional functions for backwards compatibility */ void graphics_on PROTO((void)); void graphics_off PROTO((void)); /* Prototypes for mouse handling functions. The mousex( ) and mousey( ) * functions return the most recent x and y coordinates detected from the * mouse. For the other functions, the kind parameter should be one of these: * WM_MOUSEMOVE -- mouse movement * WM_LBUTTONDBLCLK -- left mouse button double-click * WM_LBUTTONDOWN -- left mouse button pushed down * WM_LBUTTONUP -- left mouse button released up * WM_MBUTTONDBLCLK -- middle mouse button double-click (might not work!) * WM_MBUTTONDOWN -- middle mouse button pushed down (might not work!) * WM_MBUTTONUP -- middle mouse button released up (might not work!) * WM_RBUTTONDBLCLK -- right mouse button double-click * WM_RBUTTONDOWN -- right mouse button pushed down * WM_RBUTTONUP -- right mouse button released up * The parameter h must be a void function with two integer parameters. * This function will be called whenever the corresponding event occurs. * The two integer parameters will be the x- and y-coordinates where the * event happened. * * NOTE: The middle button events aren't being caught on my Windows 95 system. * I don't know why. * Added by Michael Main -- 11/3/98 and 10/4/99 and 12/21/99. */ int mousex PROTO(( )); int mousey PROTO(( )); void registermousehandler PROTO((UINT kind, void h(int, int))); //bool ismouseclick PROTO((UINT kind)); //void getmouseclick PROTO((UINT kind, int& x, int& y)); void clearmouseclick PROTO((UINT kind)); /* Prototypes for other new functions, not in the original BGI graphics. * There is also a new initwindow function that can be called instead of * initgraph. The arguments are an explicit width and height. * As of 11/3, the width is now the first parameter. * The getactivepage() and getvisualpage() functions get the number of the * current active or visual page. */ void initwindow PROTO((int, int)); int getactivepage PROTO(( )); int getvisualpage PROTO(( )); /* Colors can be original bgi colors (ints in the range 0...MAXCOLORS) or * RGB colors constructed from red, green and blue components between * 0 and 255. * IS_BGI_COLOR(v): true if v is one of the original BGI colors * IS_RGB_COLOR(v): true if v is one of the new RGB colors * RED_VALUE(v) is the red value of an RGB color v * GREEN_VALUE(v) is the red value of an RGB color v * BLUE_VALUE(v) is the red value of an RGB color v * COLOR(r,g,b): is the rgb color formed from a red, green and blue * value (all in the range 0...255). */ #define IS_BGI_COLOR(c) (((c) >= 0) && ((c) <= MAXCOLORS)) #define IS_RGB_COLOR(c) ((c) & 0x04000000) #define RED_VALUE(v) ((v) & 0xFF) #define GREEN_VALUE(v) (((v) >> 8) & 0xFF) #define BLUE_VALUE(v) (((v) >> 16)& 0xFF) #define COLOR(r,g,b) (0x04000000 | RGB(r,g,b)) #if defined(__cplusplus) }; #endif #endif

the bit of code flagged is:

Code:
//First define "this_line" as a pointer. void display_line(line_type *this_line) //"display_line" = "draw_line" {

it doesn't like this one... 4 of the 5 errors are on it...

the other is just the "}" right at the very end of the prog.

I'm pretty sure it's my crappy code that's to blame... I'll bet I've just not finished some part of it... as I say I'm too tired to play with it now, but I'll be spending most of tomorrow morning (GMT) on it.

(beddie byes for me i think: i'm knackered!)
  #6  
Old 14-May-2007, 19:33
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 385
Howard_L has a spectacular aura aboutHoward_L has a spectacular aura about

Re: Linked Lists advice request


If you're still trying the code you have above I bet you're having problems. A nap sounds like a good idea! I saw potential nested comments, and a second main() for starters! Even after some cleanup and commenting out of more sections than you already had I still get a screen full of errors. Most about variables being out of scope and such. Nothing about graphics.h.

I thought you were getting good compiles with the graphics_lib.h you have. I am using the cs1300 ming32 stuff I got from here:
'http://www.cs.colorado.edu/~main/cs1300/doc/bgi/bgi.html'
(gcc in windows... dude!)

They call their winbgim library 'graphics.h' and it's updated a/o 2004.
It is in the 'includes' directory and I use '#includes <graphics.h>' .
There is also the 'libbgi.a' which is put in the 'lib' directory.
It is linked as I compile somehow, I don't see it in graphics.h...
Both files are available seperately. They also come with the full 30mb install.

Try a smaller program, get a good compile, and THEN move on.
Howard;
  #7  
Old 14-May-2007, 20:47
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,520
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Linked Lists advice request


Quote:
Originally Posted by promsan
The Graphics_lib.h is


the bit of code flagged is:

Code:
//First define "this_line" as a pointer. void display_line(line_type *this_line) //"display_line" = "draw_line" {
And where is this line relative to the #include statement for the header? Show some context please. (What are the 30 lines before this one?)
Quote:
Originally Posted by promsan
it doesn't like this one... 4 of the 5 errors are on it...
Are the errors the ones from your previous post?
Quote:
Originally Posted by promsan
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(31) : error C2143: syntax error : missing ')' before '*'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(31) : error C2143: syntax error : missing '{' before '*'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(31) : error C2059: syntax error : ')'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(32) : error C2054: expected '(' to follow 'this_line'
If so, then it probably doesn't know what "line_type" is. There would have had to be a typedef somewhere before this statement. Where is it? Not in the header file that you posted. (Or, at least I don't see it.)

I note that you have included two non-standard headers here.
<windows.h> from Microsoft has been copied (presumably licensed) by numerous other compiler vendors, but may not be exactly the same. I doubt that this is the problem.

For <conio.h>, the functions prototyped there (and the corresponding library functions provided by the vendor) may be completely different from a <conio.h> from another vendor. Compilers from Borland have almost completely different functions prototyped in <conio.h> than from those Microsoft. Even different versions of Borland compilers have different functions thatn other versions of Borland compilers (!)

If you can't get past line 31/32, then maybe you are missing something from one of the other headers. Note that simply copying a header file (or some function prototype) from some other distribution will not work, since it requires the actual function to be in your project somewhere (either in a library file or in some source code file.

That's the problem with programs using other people's code with non-standard implementation-dependent headers and library functions. Even if they try to use conditional compilation flags (all of those confusing [klbd]#If defined[/kbd] thingies), it may work for some compilers and not for others.


So: The first thing is to work on the first error. What is "line_type" and where is it defined. Then go from there.

Regards,

Dave
  #8  
Old 15-May-2007, 02:51
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road

Re: Linked Lists advice request


Hi Dave,

Cheers for that

...after removing the second "main()" I shifted the other two #includes i'd forgotten about.

I recompiled and got similar errors:



The context of the error you asked about is
Code:
#include <graphics_lib.h> #include <math.h> #include <conio.h> //First define "this_line" as a pointer. void display_line(line_type *this_line) //"display_line" = "draw_line" { /* Open a graphics window */ //initwindow(800, 600); /* Set the colour */ setcolor(this_line->colour); //to set colour of line. the arrow dereferernces the * /* Draw the line line(this_line->start_x,this_line->start_y,this_line->end_x,this_line->end_y); //to set a co-ord to draw line } void get_line(line_type *line_pointer) //line is a pointer to a line type {

NB: I have changed the graphics_lib.h to sit betwixt " " rather than < > as you said.

...aah see, from checking my old code I copied this from, I've changed "line_type" to "shape" but only on the typedef... time for some whittling...
  #9  
Old 15-May-2007, 02:52
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road

Re: Linked Lists advice request


Quote:
Originally Posted by promsan
Hi Dave,

Cheers for that

...after removing the second "main()" I shifted the other two #includes i'd forgotten about.

I recompiled and got similar errors:



The context of the error you asked about is
Code:
#include <graphics_lib.h> #include <math.h> #include <conio.h> //First define "this_line" as a pointer. void display_line(line_type *this_line) //"display_line" = "draw_line" { /* Open a graphics window */ //initwindow(800, 600); /* Set the colour */ setcolor(this_line->colour); //to set colour of line. the arrow dereferernces the * /* Draw the line line(this_line->start_x,this_line->start_y,this_line->end_x,this_line->end_y); //to set a co-ord to draw line } void get_line(line_type *line_pointer) //line is a pointer to a line type {

NB: I have changed the graphics_lib.h to sit betwixt " " rather than < > as you said.

...aah see, from checking my old code I copied this from, I've changed "line_type" to "shape" but only on the typedef... time for some whittling...


Quote:
Deleting intermediate files and output files for project 'shapeshifter - Win32 Debug'.
--------------------Configuration: shapeshifter - Win32 Debug--------------------
Compiling...
shapeshifter.c
m:\w2k\clab\shapeshifter\shapeshifter.c(77) : error C2143: syntax error : missing ';' before 'type'
m:\w2k\clab\shapeshifter\shapeshifter.c(103) : error C2065: 'size' : undeclared identifier
m:\w2k\clab\shapeshifter\shapeshifter.c(10 : error C2143: syntax error : missing ';' before 'type'
m:\w2k\clab\shapeshifter\shapeshifter.c(109) : error C2143: syntax error : missing ';' before 'type'
m:\w2k\clab\shapeshifter\shapeshifter.c(110) : error C2143: syntax error : missing ';' before 'type'
m:\w2k\clab\shapeshifter\shapeshifter.c(112) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'void (__cdecl *)(int ,int ,int ,int )'
m:\w2k\clab\shapeshifter\shapeshifter.c(112) : warning C4024: 'fgets' : different types for formal and actual parameter 1
m:\w2k\clab\shapeshifter\shapeshifter.c(114) : error C2065: 'new' : undeclared identifier
m:\w2k\clab\shapeshifter\shapeshifter.c(114) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct llist *'
m:\w2k\clab\shapeshifter\shapeshifter.c(115) : error C2223: left of '->next' must point to struct/union
m:\w2k\clab\shapeshifter\shapeshifter.c(115) : error C2065: 'head' : undeclared identifier
m:\w2k\clab\shapeshifter\shapeshifter.c(117) : error C2223: left of '->str' must point to struct/union
m:\w2k\clab\shapeshifter\shapeshifter.c(117) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'void (__cdecl *)(int ,int ,int ,int )'
m:\w2k\clab\shapeshifter\shapeshifter.c(117) : warning C4024: 'strdup' : different types for formal and actual parameter 1
m:\w2k\clab\shapeshifter\shapeshifter.c(120) : warning C4047: '!=' : 'int ' differs in levels of indirection from 'void *'
m:\w2k\clab\shapeshifter\shapeshifter.c(122) : error C2223: left of '->str' must point to struct/union
m:\w2k\clab\shapeshifter\shapeshifter.c(123) : error C2223: left of '->next' must point to struct/union
m:\w2k\clab\shapeshifter\shapeshifter.c(130) : error C2143: syntax error : missing ';' before 'type'
m:\w2k\clab\shapeshifter\shapeshifter.c(140) : warning C4013: 'newelement' undefined; assuming extern returning int
m:\w2k\clab\shapeshifter\shapeshifter.c(140) : warning C4047: '=' : 'struct list *' differs in levels of indirection from 'int '
m:\w2k\clab\shapeshifter\shapeshifter.c(141) : error C2037: left of 'val' specifies undefined struct/union 'list'
m:\w2k\clab\shapeshifter\shapeshifter.c(142) : error C2037: left of 'next' specifies undefined struct/union 'list'
m:\w2k\clab\shapeshifter\shapeshifter.c(142) : error C2065: 'p' : undeclared identifier
m:\w2k\clab\shapeshifter\shapeshifter.c(143) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct list *'
m:\w2k\clab\shapeshifter\shapeshifter.c(149) : warning C4047: '=' : 'struct list *' differs in levels of indirection from 'int '
m:\w2k\clab\shapeshifter\shapeshifter.c(150) : error C2037: left of 'val' specifies undefined struct/union 'list'
m:\w2k\clab\shapeshifter\shapeshifter.c(151) : error C2037: left of 'next' specifies undefined struct/union 'list'
m:\w2k\clab\shapeshifter\shapeshifter.c(152) : warning C4047: '==' : 'int ' differs in levels of indirection from 'void *'
m:\w2k\clab\shapeshifter\shapeshifter.c(153) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct list *'
m:\w2k\clab\shapeshifter\shapeshifter.c(157) : warning C4047: '=' : 'struct list *' differs in levels of indirection from 'int '
m:\w2k\clab\shapeshifter\shapeshifter.c(15 : error C2037: left of 'next' specifies undefined struct/union 'list'
m:\w2k\clab\shapeshifter\shapeshifter.c(159) : error C2037: left of 'next' specifies undefined struct/union 'list'
m:\w2k\clab\shapeshifter\shapeshifter.c(160) : error C2037: left of 'next' specifies undefined struct/union 'list'
m:\w2k\clab\shapeshifter\shapeshifter.c(171) : warning C4047: '=' : 'int ' differs in levels of indirection from 'void *'
m:\w2k\clab\shapeshifter\shapeshifter.c(180) : warning C4047: '=' : 'struct list *' differs in levels of indirection from 'int '
m:\w2k\clab\shapeshifter\shapeshifter.c(184) : error C2037: left of 'val' specifies undefined struct/union 'list'
m:\w2k\clab\shapeshifter\shapeshifter.c(185) : error C2037: left of 'next' specifies undefined struct/union 'list'
m:\w2k\clab\shapeshifter\shapeshifter.c(194) : error C2143: syntax error : missing ')' before 'string'
m:\w2k\clab\shapeshifter\shapeshifter.c(194) : error C2143: syntax error : missing '{' before 'string'
m:\w2k\clab\shapeshifter\shapeshifter.c(194) : error C2059: syntax error : '<Unknown>'
m:\w2k\clab\shapeshifter\shapeshifter.c(194) : error C2059: syntax error : ')'
m:\w2k\clab\shapeshifter\shapeshifter.c(196) : error C2065: 'degree' : undeclared identifier
m:\w2k\clab\shapeshifter\shapeshifter.c(196) : error C2065: 'PI' : undeclared identifier
m:\w2k\clab\shapeshifter\shapeshifter.c(196) : error C2099: initializer is not a constant
m:\w2k\clab\shapeshifter\shapeshifter.c(197) : error C2099: initializer is not a constant
m:\w2k\clab\shapeshifter\shapeshifter.c(199) : error C2143: syntax error : missing '{' before '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(199) : error C2059: syntax error : '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(200) : error C2143: syntax error : missing '{' before '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(200) : error C2059: syntax error : '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(201) : error C2143: syntax error : missing '{' before '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(201) : error C2059: syntax error : '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(202) : error C2143: syntax error : missing '{' before '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(202) : error C2059: syntax error : '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(203) : error C2143: syntax error : missing '{' before '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(203) : error C2059: syntax error : '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(204) : error C2143: syntax error : missing '{' before '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(204) : error C2059: syntax error : '.'
m:\w2k\clab\shapeshifter\shapeshifter.c(205) : error C2059: syntax error : ','
m:\w2k\clab\shapeshifter\shapeshifter.c(205) : error C2143: syntax error : missing ')' before 'constant'
m:\w2k\clab\shapeshifter\shapeshifter.c(205) : error C2143: syntax error : missing '{' before 'constant'
m:\w2k\clab\shapeshifter\shapeshifter.c(205) : error C2059: syntax error : '<Unknown>'
m:\w2k\clab\shapeshifter\shapeshifter.c(205) : error C2059: syntax error : ')'
m:\w2k\clab\shapeshifter\shapeshifter.c(206) : error C2059: syntax error : ','
m:\w2k\clab\shapeshifter\shapeshifter.c(206) : error C2143: syntax error : missing ')' before 'constant'
m:\w2k\clab\shapeshifter\shapeshifter.c(206) : error C2143: syntax error : missing '{' before 'constant'
m:\w2k\clab\shapeshifter\shapeshifter.c(206) : error C2059: syntax error : '<Unknown>'
m:\w2k\clab\shapeshifter\shapeshifter.c(206) : error C2059: syntax error : ')'
m:\w2k\clab\shapeshifter\shapeshifter.c(209) : error C2065: 'theta' : undeclared identifier
m:\w2k\clab\shapeshifter\shapeshifter.c(209) : error C2065: 'x' : undeclared identifier
m:\w2k\clab\shapeshifter\shapeshifter.c(209) : error C2065: 'y' : undeclared identifier
m:\w2k\clab\shapeshifter\shapeshifter.c(209) : error C2099: initializer is not a constant
m:\w2k\clab\shapeshifter\shapeshifter.c(210) : error C2099: initializer is not a constant
m:\w2k\clab\shapeshifter\shapeshifter.c(214) : error C2371: 'closegraph' : redefinition; different basic types
n:\course\elec\include\graphics_lib.h(300) : see declaration of 'closegraph'
m:\w2k\clab\shapeshifter\shapeshifter.c(216) : error C2059: syntax error : 'return'
m:\w2k\clab\shapeshifter\shapeshifter.c(21 : error C2059: syntax error : '}'
Error executing cl.exe.

shapeshifter.exe - 60 error(s), 15 warning(s)

(sigh...)
  #10  
Old 15-May-2007, 06:47
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 385
Howard_L has a spectacular aura aboutHoward_L has a spectacular aura about

Re: Linked Lists advice request


Ever follow a thread only to find it was 3 BIG pages of stuff that could have been on one page?
Some of us are still on dialup!
Again, reduce your program till you get no errors.
Even if it's all the way back to printf("Hello World");
Then start adding your stuff back in until you do get errors.

When you get one you don't understand:
- post the error
- post the section of code pertinent to the error

It would save a lot of time and space. Thanks,
Howard;
PS: I don't see anything above about graphics_lib.h not being found,
looks like syntax, context and data type mostly. There are certain rules in C
Last edited by Howard_L : 15-May-2007 at 07:29. Reason: added additional info kinda
 

Recent GIDBlogUpdates On The All New Toyota VIOS - Part III by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
triangle (polygon), drawing, sizing, and rotation programme using linked lists... promsan C Programming Language 12 14-May-2007 14:03
Doubly linked lists in C++ sweeeeeeetlipss CPP / C++ Forum 1 23-Oct-2006 23:27
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 13:12
help on linked lists any1????? nick4 C Programming Language 1 17-May-2004 09:32
linked lists, newbie needs help moltarim C Programming Language 4 06-May-2004 11:32

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:40.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.