Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 4th, 2005, 3:56 PM   #1
Nish
Newbie
 
Join Date: Mar 2005
Posts: 5
Rep Power: 0 Nish is on a distinguished road
Linked List Part 2

Hi,
For the second part of my code (First Part being titled Linked List and Array of POinters) I need to fill in the Linked List with values for the line_used from a file. The file has the following format:

Array size: 17 x 17 logic blocks.

Routing:

Net 0 (i_63_)

SOURCE (18,1) Pad: 0
OPIN (18,1) Pad: 0
CHANY (17,1) Track: 2
CHANX (17,1) Track: 3
IPIN (17,1) Pin: 2
SINK (17,1) Class: 0
CHANX (17,1) Track: 2
CHANY (16,2) Track: 4
IPIN (16,2) Pin: 3
SINK (16,2) Class: 0


Hence I need to read the Channel X or Y and the coordinates and the corresponding track number. Depending on the Channel (X or Y ) and the coordinates I have to fill up the linked list.
The logic is illlustrated in my code but when I run the program on VC++ I get an error message that the exe file has encountered an error. When I try to debug it says that it cannot evaluate the line_used expression and the temp=temp->nextptr expression.

Also further I get the following errors on debugging

Loaded 'C:\WINDOWS\system32\ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\shlwapi.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\apphelp.dll', no matching symbolic information found.
The thread 0x7E8 has exited with code 0 (0x0).
The thread 0xF88 has exited with code -1073741819 (0xC0000005).


On GCC I simply get a Segmentation Fault.

I am again all confused where to try looking for tthe problem.
I tried printing out the tracknumber and coordinates also. They do print if I comment the part from **HERE** to **HERE**

I am attaching the code below:

#include<stdio.h>
#include<stdlib.h.>
 
struct switch_matrix
{
 
  int pin_no;
  int line_used;
  struct switch_matrix *nextptr;
 
};
 
struct switch_block
{
 
  struct switch_matrix *Array[40];
 
}Layout[18][18];
 
 
typedef struct switch_matrix SWITCH;
 
void build_univ_switch (struct switch_block *X);
 
 
 
 
int main()
{
  int x1=0,x2=0,y1=0,y2=0,trackno1=0,trackno2=0,m,n;
  FILE *fp;
  SWITCH *temp;
  char ch;
  
 
fp=fopen("e64.r","r");
  while(!feof(fp))
    { 
   **HERE**
      if (x1==x2)
        {
          if (y1==y2)
            { 
              temp=Layout[17-y1][x1].Array[19+trackno2];
              temp=temp->nextptr;
              temp->line_used=1; 
                       
              temp=Layout[17-y1][x1].Array[19-trackno1];
              temp=temp->nextptr; 
              temp=temp->nextptr; 
              temp->line_used=1; 
            } 
                     
          else   
            {
              if (y2==y1+1)
                {
                  temp=Layout[17-y1][x1].Array[19-trackno1];
                  temp->line_used=1;
             
                  temp=Layout[17-y1][x1].Array[9-trackno2];
                  temp=temp->nextptr;
                  temp->line_used=1; 
                } 
              else   
                {
                  if (y2 > y1+1) 
                    { 
                      temp=Layout[17-(y2-1)][x1].Array[19+trackno2];
                      temp->line_used=1;
               
                      temp=Layout[17-(y2-1)][x1].Array[9-trackno2];
                      temp=temp->nextptr;
                      temp=temp->nextptr;
                      temp->line_used=1;
                    }
                }
            }
        } 
      else 
        { 
          if (y1==y2) 
            {
              if (x1==x2+1) 
                { 
                  temp=Layout[17-y2][x2].Array[19+trackno2];
                  temp=temp->nextptr;
                  temp=temp->nextptr;
                  temp=temp->nextptr;
                  temp->line_used=1;
                      
                  temp=Layout[17-y2][x2].Array[29+trackno1]; 
                  temp=temp->nextptr;   
                  temp=temp->nextptr;
                  temp->line_used=1; 
                } 
              else 
                { 
                  if (x1 > x2+1)
                    {
                      temp=Layout[17-y1][x1-1].Array[19-trackno1];
                      temp=temp->nextptr;
                      temp=temp->nextptr;
                      temp=temp->nextptr;
                      temp->line_used=1;
             
                      temp=Layout[17-y1][x1-1].Array[29+trackno1];
                      temp=temp->nextptr;
                      temp->line_used=1; 
                    } 
                } 
            } 
          else 
            {         
              if (y2==y1+1) 
                { 
                  temp=Layout[17-y1][x2].Array[9-trackno2];
                  temp=temp->nextptr;
                  temp=temp->nextptr;
                  temp=temp->nextptr;
                  temp->line_used=1;
                   
                  temp=Layout[17-y1][x2].Array[29+trackno1];
                  temp->line_used=1; 
                } 
            }
			  
        } **HERE**
	  

		
                       
             
      ch=fgetc(fp); 
      if (ch=='S') 
        { 
          x1 = 0; 
          y1 = 0; 
          x2 = 0;
          y2 = 0;
                      
          ch=fgetc(fp); 
          if(ch=='C')
            { 
              ch=fgetc(fp); 
              if(ch=='H') 
                { 
                  ch=fgetc(fp); 
                  if(ch=='A')
                    { 
                      ch=fgetc(fp);  
                      if(ch=='N')
                        {
                          ch=fgetc(fp);
                          if(ch=='X')
                            {
                              ch=fgetc(fp);//the blank
                              //ch=fgetc(fp);//the colon
                              ch=fgetc(fp);//the (
                              fscanf(fp,"%d",&x1);
                              printf("%d\n",x1); 
                              ch=fgetc(fp);//the ,
                              fscanf(fp,"%d",&y1); 
                              printf("%d\n",y1); 
                              for(m=0;m<10;m++)//no of charac till u reach track no
                                ch=fgetc(fp);
                              fscanf(fp,"%d",&trackno1); 
                              printf("go\n");
                              printf("%d\n",trackno1);
                     
                   
                              //store these in the linked list
                            }
                          else if (ch=='Y')
                            {
                              ch=fgetc(fp);//the blank
                              //ch=fgetc(fp);//the colon
                              ch=fgetc(fp);//the (
                              fscanf(fp,"%d",&x2);
                              printf("%d\n",x2);
                              ch=fgetc(fp);//the ,
                              fscanf(fp,"%d",&y2);
                              printf("%d\n",y2);
                              for(n=0;n<10;n++)//no of charac till u reach track no
                                ch=fgetc(fp); 
                              fscanf(fp,"%d",&trackno2);
                              printf("%d\n",trackno2);
                               
                                 
                              //store these in the linked list
                            } 
                        } 
                    }
                }  
            } 
        } 
                           
    } 
  fclose(fp); 
                               
  return 0; 
} 
                               
void build_univ_switch(struct switch_block *X) 
{ 
  SWITCH *head; 
  SWITCH *currentptr; 
  int i, j; 
                               
                               
                               
                                 
  for (i = 0; i<40; i++) 
    { 
                          
      /*BUILDS LINKED LIST*/
      head = NULL; 
      for (j = 1; j<=4; j++)
        { 
          currentptr = (SWITCH *) malloc (sizeof (SWITCH));
          currentptr->line_used = 0;
          currentptr->nextptr = head;
          head = currentptr;   
        }   
      //currentptr = head;
      X->Array[i] = head;      
    } 
  
}


I am open to any help as I can get regarding this.
Nish is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:08 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC