ordered linked list

Reply

Join Date: Jul 2006
Posts: 17
Reputation: mitchelltab is an unknown quantity at this point 
Solved Threads: 0
mitchelltab mitchelltab is offline Offline
Newbie Poster

ordered linked list

 
0
  #1
Oct 14th, 2006
I'm having trouble calling my linked list of Insernode. Can some one help me please.
I need ot call it when it read teh data from teh file and puts it in the lists. I also need to use the list once i eneter in there data. adn if i enter is is there a way toadd the data the comparie inser the data that i have into file saved file.


 #include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Nlen    26
typedef struct person_t {
   char FName[Nlen];
   char LName[Nlen];
   char Sex;
   char Grade;
   struct person_t *Next;
  } PERSON;

/*********************************************************************
 Funstion to Ordered linked list
 This is where i will call the Last name and put it into the linked   
 list ordered by last name. 
 
********************************************************************/
PERSON* InsertNode (PERSON *Top, PERSON *Node )
{
PERSON *Here, /* Node being compared to new node */  
*Prev; /* Node in front of Here node */
if (Top == NULL)/* List is empty – Place new node at top of list */
Top = Node;
else { /* Top != NULL *//* Start at Top of list */
Here = Top;
if (Here->LName > Node->LName) {               
Node->Next = Top;
Top = Node;
}
else {/* Search for place to insert new node */
Prev = Top;
Here = Prev->Next;
while ( (Here != NULL) &&
(Here->LName < Node->LName) ) {
Prev = Here;
Here = Here->Next;
}/* Insert into list at found spot */
Node->Next = Prev->Next;
Prev->Next = Node;
}
} /* end of Top != NULL */
return Top;
}
/*************************************************************
end of  Funstion to Ordered linked list
***************************************************************/
void amend_file( char file[], PERSON *STU ); 
void show_file( char file[], PERSON *STU );

int main (void)
{
   PERSON *STU;
   int Ans;
        char file[] = "data.txt";
    int Records [100];
    
    
  do
   {
      printf("\n\n"
             "1. Enter new record\n"
             "2. Display List\n"
             "3. Quit\n\n");
      printf("Prompt: ");
      fflush(stdout);
      if ( scanf("%d", &Ans) == 1 ) /* get answer */
      {
         STU = (PERSON*) malloc (sizeof (PERSON));
         if (STU == NULL)
         {
            perror("PERSON");
            exit(EXIT_FAILURE);
         }
         switch(Ans)
         {
            case 1:
               amend_file(file, STU);  //calls the amend file funcation
                InsertNode;  //calls the insert Node funcation  which it is not getting into becuase
                //Im haveing issues with getting the file to print. 
              break;
            case 2:
               show_file(file, STU);  //calls teh show file funcation
               break;
            case 3: default:
               Ans = 3;
               break;
         }
      } /* /get answer */
   }
    while ( Ans != 3 );
    
      fflush(stdout);
      free(STU);
   return EXIT_SUCCESS;
}
/*************************************************************************
* amend_file: Enter stuff into the working file.
*
**************************************************************************/
void amend_file( char file[], PERSON *STU )
{
   assert(STU != NULL);
   FILE *fin = fopen(file, "a+");
   if ( fin == NULL )
   {
      perror(file);
      exit(EXIT_FAILURE);
   }
   printf("Enter new record: ");
   printf ("\nEnter students First name ( up to %d letters):", Nlen);
   printf ("\nEnter students  Last name  ( up to %d letters):", Nlen);
   printf ("\nPlease enter Sex");
   printf ("\nPlease enter Grade\n");
   scanf("%s %s %c %c", STU->FName, STU->LName, &STU->Sex,
      &STU->Grade);
    fprintf(fin, "%s %s %c %c\n", STU->LName, STU->FName, STU->Sex, STU->Grade);
           fflush(fin);
            fclose(fin);  
      }
/******************************************************************************
* show_file: Reads the working file.
* Bare bones again...
******************************************************************************/
void show_file ( char file[], PERSON *STU )
{
  assert(STU != NULL);
  int b = 1;
  FILE *fout = fopen(file, "r");
    
  if (file == NULL)
  {
    perror(file);
    exit(EXIT_FAILURE);
  }
  while (fscanf(fout, "%s %s %c %c", STU->FName, STU->LName, &STU->Sex,
     &STU->Grade) == 4)
  {              
    printf("Record %d: %s %s %c %c\n", b, STU->FName, STU->LName,
       STU->Sex, STU->Grade);
    b++;
 // }
  fclose(fout);
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,358
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: ordered linked list

 
0
  #2
Oct 14th, 2006
I compiled and ran it with Dev-C++ and it seemed to work ok. The only change I had to make was to flush the input stream after selecting a menu. You should not use scanf() especially with strings because it will allow you to type more characters than the input buffer will hold, causing buffer overflow. It also leaves <Enter> keys in the keyboard buffer so that the next time you call scanf() or getchar() these functions will not appear to do anything. The standard C solution is to use fgets() to get the inputs when use atol() to convert the input buffer to integer when necessary. For example:
  1. fgets(STU->FName,sizeof(STU->FName),stdin);
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 17
Reputation: mitchelltab is an unknown quantity at this point 
Solved Threads: 0
mitchelltab mitchelltab is offline Offline
Newbie Poster

Re: ordered linked list

 
0
  #3
Oct 14th, 2006
i changed that just for some reason its not getting into the linked list and sorting it. I did chagne the code here it is
  1. #include <assert.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #define Nlen 26
  6. typedef struct person_t {
  7. char FName[Nlen];
  8. char LName[Nlen];
  9. char Sex;
  10. char Grade;
  11. struct person_t *Next;
  12. } PERSON;
  13. struct person_t *Top = NULL;
  14. struct person_t *Node = NULL;
  15. /*********************************************************************
  16.  Funstion to Ordered linked list
  17.  This is where i will call the Last name and put it into the linked
  18.  list ordered by last name.
  19.  
  20. ********************************************************************/
  21. PERSON* InsertNode (PERSON *Top, PERSON *Node )
  22. {
  23. PERSON *Here, /* Node being compared to new node */
  24. *Prev; /* Node in front of Here node */
  25. if (Top == NULL)/* List is empty – Place new node at top of list */
  26. Top = Node;
  27. else { /* Top != NULL *//* Start at Top of list */
  28. Here = Top;
  29. if (Here->LName > Node->LName) {
  30. Node->Next = Top;
  31. Top = Node;
  32. }
  33. else {/* Search for place to insert new node */
  34. Prev = Top;
  35. Here = Prev->Next;
  36. while ( (Here != NULL) &&
  37. (Here->LName < Node->LName) ) {
  38. Prev = Here;
  39. Here = Here->Next;
  40. }/* Insert into list at found spot */
  41. Node->Next = Prev->Next;
  42. Prev->Next = Node;
  43. }
  44. } /* end of Top != NULL */
  45. return Top;
  46. }
  47. /*************************************************************
  48. end of Funstion to Ordered linked list
  49. ***************************************************************/
  50. void amend_file( char file[], PERSON *STU );
  51. void show_file( char file[], PERSON *STU );
  52.  
  53. int main (void)
  54. {
  55. PERSON *STU;
  56. int Ans;
  57. char file[] = "data.txt";
  58. int Records [100];
  59. FILE *fin = fopen(file, "a+");
  60. struct person_t *Top = NULL;
  61. struct person_t *Node = NULL;
  62.  
  63.  
  64.  
  65. do
  66. {
  67. printf("\n\n"
  68. "1. Enter new record\n"
  69. "2. Display List\n"
  70. "3. Quit\n\n");
  71. printf("Prompt: ");
  72. fflush(stdout);
  73. if ( scanf("%d", &Ans) == 1 ) /* get answer */
  74. {
  75. fgets(STU->FName,sizeof(STU->FName),stdin);
  76. if (STU == NULL)
  77. {
  78. perror("PERSON");
  79. exit(EXIT_FAILURE);
  80. }
  81. switch(Ans)
  82. {
  83. case 1:
  84. amend_file(file, STU); //calls the amend file funcation
  85. break;
  86. case 2:
  87. show_file(file, STU); //calls teh show file funcation
  88. break;
  89. case 3: default:
  90. Ans = 3;
  91. break;
  92. }
  93. } /* /get answer */
  94. }
  95. while ( Ans != 3 );
  96.  
  97. fflush(stdout);
  98. free(STU);
  99. getchar ();
  100. return EXIT_SUCCESS;
  101. }
  102. /*************************************************************************
  103. * amend_file: Enter stuff into the working file.
  104. *
  105. **************************************************************************/
  106. void amend_file( char file[], PERSON *STU )
  107. {
  108. assert(STU != NULL);
  109. FILE *fin = fopen(file, "a+");
  110. if ( fin == NULL )
  111. {
  112. perror(file);
  113. exit(EXIT_FAILURE);
  114. }
  115. printf("Enter new record: ");
  116. printf ("\nEnter students First name ( up to %d letters):", Nlen);
  117. printf ("\nEnter students Last name ( up to %d letters):", Nlen);
  118. printf ("\nPlease enter Sex");
  119. printf ("\nPlease enter Grade\n");
  120. scanf("%s %s %c %c", STU->FName, STU->LName, &STU->Sex,
  121. &STU->Grade);
  122. Top = InsertNode (Top, Node); //calls the insert Node funcation which it is not getting into becuase
  123. //Im haveing issues with getting the file to print.
  124. fprintf(fin, "%s %s %c %c\n", STU->LName, STU->FName, STU->Sex, STU->Grade);
  125. fflush(fin);
  126. fclose(fin);
  127. }
  128. /******************************************************************************
  129. * show_file: Reads the working file.
  130. * Bare bones again...
  131. ******************************************************************************/
  132. void show_file ( char file[], PERSON *STU )
  133. {
  134. assert(STU != NULL);
  135. int b = 1;
  136. FILE *fin = fopen(file, "r");
  137.  
  138. if (file == NULL)
  139. {
  140. perror(file);
  141. exit(EXIT_FAILURE);
  142. }
  143. while (fscanf(fin, "%s %s %c %c", STU->FName, STU->LName, &STU->Sex,
  144. &STU->Grade)== 4)
  145. {
  146. Top = InsertNode (Top, Node); //read insernode function
  147. b++;
  148. printf("Record %d: %s %s %c %c\n", b, STU->FName, STU->LName,
  149. STU->Sex, STU->Grade);
  150. }
  151. fclose(fin);
  152. }
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 17
Reputation: mitchelltab is an unknown quantity at this point 
Solved Threads: 0
mitchelltab mitchelltab is offline Offline
Newbie Poster

Re: ordered linked list

 
0
  #4
Oct 17th, 2006
ok I did that cahnge. I'm still not able to get the code to go into the linked list any help to what or where i messed up please
  1. #include <assert.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #define Nlen 26
  6. typedef struct person_t {
  7. char FName[Nlen];
  8. char LName[Nlen];
  9. char Sex;
  10. char Grade;
  11. struct person_t *Next;
  12. } PERSON;
  13. struct person_t *Top = NULL;
  14. struct person_t *Node = NULL;
  15. /*********************************************************************
  16.  Funstion to Ordered linked list
  17.  This is where i will call the Last name and put it into the linked
  18.  list ordered by last name.
  19.  
  20. ********************************************************************/
  21. PERSON* InsertNode (PERSON *Top, PERSON *Node )
  22. {
  23. PERSON *Here, /* Node being compared to new node */
  24. *Prev; /* Node in front of Here node */
  25. if (Top == NULL)/* List is empty – Place new node at top of list */
  26. Top = Node;
  27. else { /* Top != NULL *//* Start at Top of list */
  28. Here = Top;
  29. if (Here->LName > Node->LName) {
  30. Node->Next = Top;
  31. Top = Node;
  32. }
  33. else {/* Search for place to insert new node */
  34. Prev = Top;
  35. Here = Prev->Next;
  36. while ( (Here != NULL) &&
  37. (Here->LName < Node->LName) ) {
  38. Prev = Here;
  39. Here = Here->Next;
  40. }/* Insert into list at found spot */
  41. Node->Next = Prev->Next;
  42. Prev->Next = Node;
  43. }
  44. } /* end of Top != NULL */
  45. return Top;
  46. }
  47. /*************************************************************
  48. end of Funstion to Ordered linked list
  49. ***************************************************************/
  50. void amend_file( char file[], PERSON *STU );
  51. void show_file( char file[], PERSON *STU );
  52.  
  53. int main (void)
  54. {
  55. PERSON *STU;
  56. int Ans;
  57. char file[] = "e:data.txt";
  58. int Records [100];
  59. FILE *fin = fopen(file, "a+");
  60. struct person_t *Top = NULL;
  61. struct person_t *Node = NULL;
  62.  
  63.  
  64.  
  65. do
  66. {
  67. printf("\n\n"
  68. "1. Enter new record\n"
  69. "2. Display List\n"
  70. "3. Quit\n\n");
  71. printf("Prompt: ");
  72. fflush(stdout);
  73. if ( scanf("%d", &Ans) == 1 ) /* get answer */
  74. {
  75. fgets(STU->FName,sizeof(STU->FName),stdin);
  76. if (STU == NULL)
  77. {
  78. perror("PERSON");
  79. exit(EXIT_FAILURE);
  80. }
  81. switch(Ans)
  82. {
  83. case 1:
  84. amend_file(file, STU); //calls the amend file funcation
  85. break;
  86. case 2:
  87. show_file(file, STU); //calls teh show file funcation
  88. break;
  89. case 3: default:
  90. Ans = 3;
  91. break;
  92. }
  93. } /* /get answer */
  94. }
  95. while ( Ans != 3 );
  96.  
  97. fflush(stdout);
  98. free(STU);
  99. getchar ();
  100. return EXIT_SUCCESS;
  101. }
  102. /*************************************************************************
  103. * amend_file: Enter stuff into the working file.
  104. *
  105. **************************************************************************/
  106. void amend_file( char file[], PERSON *STU )
  107. {
  108. assert(STU != NULL);
  109. FILE *fin = fopen(file, "a+");
  110. if ( fin == NULL )
  111. {
  112. perror(file);
  113. exit(EXIT_FAILURE);
  114. }
  115. printf("Enter new record: ");
  116. printf ("\nEnter students First name ( up to %d letters):", Nlen);
  117. printf ("\nEnter students Last name ( up to %d letters):", Nlen);
  118. printf ("\nPlease enter Sex");
  119. printf ("\nPlease enter Grade\n");
  120. scanf("%s %s %c %c", STU->FName, STU->LName, &STU->Sex,
  121. &STU->Grade);
  122. Top = InsertNode (Top, Node); //calls the insert Node funcation which it is not getting into becuase
  123. //Im haveing issues with getting the file to print.
  124. fprintf(fin, "%s %s %c %c\n", STU->LName, STU->FName, STU->Sex, STU->Grade);
  125. fflush(fin);
  126. fclose(fin);
  127. }
  128. /******************************************************************************
  129. * show_file: Reads the working file.
  130. * Bare bones again...
  131. ******************************************************************************/
  132. void show_file ( char file[], PERSON *STU )
  133. {
  134. assert(STU != NULL);
  135. int b = 1;
  136. FILE *fin = fopen(file, "r");
  137.  
  138. if (file == NULL)
  139. {
  140. perror(file);
  141. exit(EXIT_FAILURE);
  142. }
  143. while (fscanf(fin, "%s %s %c %c", STU->FName, STU->LName, &STU->Sex,
  144. &STU->Grade)== 4)
  145. {
  146. Top = InsertNode (Top, Node); //read insernode function
  147. b++;
  148. printf("Record %d: %s %s %c %c\n", b, STU->FName, STU->LName,
  149. STU->Sex, STU->Grade);
  150. }
  151. fclose(fin);
  152. }
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: ordered linked list

 
0
  #5
Oct 17th, 2006
Please localize the errors or the problem areas so that we can help you out. Just dumping this big code is a bit daunting to read. Tell us which of your functions are not functioning properly and post only those. Eg. is the insertion going on properly, is there problem appearing in append_file etc..
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,358
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: ordered linked list

 
0
  #6
Oct 17th, 2006
When I compiled your code I got a warning in function main() that variable STU was being used before it is initialized. You need to make certain you fix all warnings as well as errors because most of the time warnings such as this one are actually errors.

  1. fgets(STU->FName,sizeof(STU->FName),stdin);
The above is the offending line. STU has not been initialized to point to anything.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2
Reputation: Lucanio is an unknown quantity at this point 
Solved Threads: 0
Lucanio Lucanio is offline Offline
Newbie Poster

Re: ordered linked list

 
0
  #7
Oct 18th, 2006
Anyone with some help my program does not want to read right and display it i need help kinda fast. Thanks


  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. #include<graphics.h>
  5. #include <math.h>
  6. #define ROWNO 11
  7. #define COLNO 11
  8. #define XVAL 40
  9. #define YVAL 40
  10. #define SIZE 20
  11.  
  12. struct Node
  13. {
  14. int x, y, points,state;
  15. struct Node *n,*p,*u,*d;
  16.  
  17. };
  18. struct Node *createLList(struct Node *hPtr,int gold, int trap)
  19. {
  20. struct Node *newptr, *curr,*top,*left,*above;
  21. int x = 0,y = 0,j;
  22.  
  23. newptr = (struct Node *) malloc (sizeof(struct Node));
  24.  
  25. newptr->x = XVAL + x * SIZE;
  26. newptr->y = YVAL + y * SIZE;
  27. newptr->state = 0;
  28. newptr->points = 0;
  29. newptr->n = newptr;
  30. newptr->p = newptr;
  31. hPtr = curr = left = above = newptr;
  32. j=rand() %10;
  33. if((j==1)&&(gold))
  34. {curr->points=5;
  35. gold--;}
  36. if((j==2)&&(trap))
  37. {curr->points=-3;
  38. trap--;}
  39. for(y=1; y<=11; y++)
  40. {
  41.  
  42. for(x=1; x<=10; x++)
  43. {
  44. j=rand() %10;
  45. if((j==1)&&(gold))
  46. {curr->points=5;
  47. gold--;}
  48. if((j==2)&&(trap))
  49. {curr->points=-3;
  50. trap--;}
  51. newptr = (struct Node *) malloc (sizeof(struct Node));
  52. newptr->x = XVAL + x * SIZE;
  53. newptr->y = YVAL + ((y-1) * SIZE);
  54. newptr->state = 0;
  55. newptr->points = 0;
  56. newptr->p = curr;
  57. curr->n = newptr;
  58. newptr->n = left;
  59. left->p = newptr;
  60. curr = newptr;
  61.  
  62. above = above->n;
  63. top=top->n;
  64. newptr->u = above;
  65. above->d = newptr;
  66. newptr->d = top;
  67. top->u = newptr;
  68. if((y==11)&&(x==10))
  69. goto endd;
  70. }
  71. x=0;
  72. top = hPtr;
  73. above = left;
  74. j=rand() %10;
  75. if((j==1)&&(gold))
  76. {curr->points=5;
  77. gold--;}
  78. if((j==2)&&(trap))
  79. {curr->points=-3;
  80. trap--;}
  81. newptr = (struct Node *) malloc (sizeof(struct Node));
  82. newptr->x = XVAL + x * SIZE;
  83. newptr->y = YVAL + y * SIZE;
  84. newptr->state = 0;
  85. newptr->points = 0;
  86. newptr->u = above;
  87. newptr->d = top;
  88. top->u = newptr;
  89. above->d = newptr;
  90. left = newptr;
  91. curr = left;
  92. }
  93. endd:
  94. return hPtr;
  95. }
  96. void drawAll(struct Node *hptr,struct Node *curr)
  97. {
  98. struct Node *temp;
  99. int x, y, row, col, color,statt;
  100. temp = curr;
  101. curr = hptr;
  102.  
  103. for(y=1;y<=11;y++)
  104. {
  105. for(x=1;x<=11;x++)
  106. {
  107. switch(curr->state)
  108. { case 0:color=15;
  109. statt=4;
  110. break;
  111. case 1:color=0;
  112. statt=1;
  113. break;
  114. }
  115. setfillstyle(statt, color);
  116. bar(curr->x,curr->y,curr->x+15,curr->y+15);
  117. curr = curr->n;
  118. }
  119.  
  120. curr = curr->n->d;
  121. }
  122. curr = temp;
  123. setfillstyle(1, 15);
  124. bar(curr->x,curr->y,curr->x+15,curr->y+15);
  125. }
  126. int main(int argc,char *argv[])
  127. {
  128.  
  129. int gd = DETECT, gm;
  130. char key;
  131. int i , j,gold = 0,trap = 0,points = 0;
  132. struct Node *curr, *head;
  133. FILE *fPtr;
  134. char string[100][50];
  135. // initgraph(&gd, &gm, "e:\\prog\\TC\\bgi\\");
  136. initgraph(&gd, &gm, "c:\\TC\\bgi\\");
  137. head=createLList(head,atoi(argv[1]),atoi(argv[2]));
  138. curr = head;
  139.  
  140. fPtr = fopen("e:\\test.dat", "r");
  141. if(fPtr == NULL)
  142. { cprintf("Error, File could not be opened\n\r");
  143. getch();
  144. goto end;}
  145. else
  146. { i=1;
  147. while(1)
  148. {
  149. fscanf(fPtr, "%s", string[i]);
  150. if(feof(fPtr))
  151. break;
  152.  
  153. if(atoi(string[i]) == 1)
  154. curr->state = 1;
  155. else if(atoi(string[i]) == 0)
  156. curr->state = 0;
  157. if(i==12)
  158. {curr = curr->n->d;
  159. i=1;}
  160. else
  161. curr = curr->n;
  162. i++;
  163. }
  164.  
  165. fclose(fPtr);
  166. }
  167. drawAll(head,curr);
  168.  
  169. while(1)
  170. {key = getch();
  171. if(key == 0)
  172. {key = getch();}
  173. if(key == 0x1b)
  174. break;
  175. if(points<0)
  176. break;
  177. switch(key)
  178. { case 0x4b:if(curr->p->state == 0)
  179. curr = curr->p;
  180. break;
  181. case 0x4d:if(curr->n->state == 0)
  182. curr = curr->n;
  183. break;
  184. case 0x48:if(curr->u->state == 0)
  185. curr = curr->u;
  186. break;
  187. case 0x50:if(curr->d->state == 0)
  188. curr = curr->d;
  189. break;
  190. }
  191. drawAll(head,curr);
  192. if(key == 13)
  193. {points = points + curr->points;
  194. switch(curr->points)
  195. { case 5:gold++;
  196. setfillstyle(1, 14);
  197. bar(curr->x,curr->y,curr->x+15,curr->y+15);
  198. break;
  199. case -3:trap++;
  200. setfillstyle(1, 4);
  201. bar(curr->x,curr->y,curr->x+15,curr->y+15);
  202. break;
  203. }
  204. sprinf(points, "No of points: %f\n", M_PI);
  205.  
  206.  
  207. }
  208.  
  209. }
  210. end:
  211. return 0;
  212. }
Last edited by WolfPack; Oct 18th, 2006 at 8:11 am. Reason: Added [CODE][/CODE] tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,358
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: ordered linked list

 
0
  #8
Oct 18th, 2006
your program is using non-standard Borland (I think) graphics functions so you might be on your own with this program.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2
Reputation: Lucanio is an unknown quantity at this point 
Solved Threads: 0
Lucanio Lucanio is offline Offline
Newbie Poster

Re: ordered linked list

 
0
  #9
Oct 19th, 2006
Thanks, well it uses a text file that it reads 2 from
example...
1 0 1 1 0 1 0 1 0 1 0
1 0 1 1 0 1 0 1 0 1 0
1 0 1 1 0 1 0 1 0 1 0
1 0 1 1 0 1 0 1 0 1 0
1 0 1 1 0 1 0 1 0 1 0
1 0 1 1 0 1 0 1 0 1 0
1 0 1 1 0 1 0 1 0 1 0
1 0 1 1 0 1 0 1 0 1 0
1 0 1 1 0 1 0 1 0 1 0
1 0 1 1 0 1 0 1 0 1 0
1 0 1 1 0 1 0 1 0 1 0
11 by 11
Then i should be able to walk on a 0 and not allowed
on a one, the program is fine just there are something wrong on left side 2 lines.Sorry bout yesterday was in a hurry.:eek:
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC