473,289 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Multiple Double Linked Lists

Hello everyone. I am trying to do the following program and am unable
to get the beginning portion to work correctly. The scanner works when
I print the statements without the double linked list portion but I
just need help with the beginning portion with the double linked lists.

Here is the information needed to understand the code:

Create 4 double linked lists as follows:

(a) A double linked list called NAMES which will contain all C like
identifiers of less than
256 characters long identified in the input file F. Each identifier
will be represented by
a triple (I, length, string) where I is used to identify the type of
the object as being an
identifier, length is an integer representing the length of the
identifier in characters, and
string is a string of characters representing the identifier itself.

(b) A double linked list called NUMBERS which will contain all C like
numbers of less than
256 characters long identified in the input file F. Each number will be
represented by a
triple (N, length, string) where N is used to identify the type of the
objects as being a
number, length is an integer representing the length of the number in
characters, and
string is the string of characters representing the number itself.

(c) A double linked list called SEPARATORS which will contain all C
language separators
and operators identified in the input file F. Each separator will be
represented by a triple
(X, length, string) where X is S for separators, O for operators, R for
symbols denoting
relations, L for new line and E for end of file. The length is an
integer representing the
length of the symbol and string is the string of characters
representing the symbol itself.

(d) A double linked list called UNKNOWN which will contain all symbols
you discovered in
the file F which could not be classi ed in the lists NAMES, NUMBERS,
SEPARATORS.
Each object in this list will be represented by a triple (Y, length,
string) where Y is used
to signify that an unknown symbol was discovered, length is an integer
representing the
length in characters of the unknown symbol, and string is the string of
characters that
make up the unknown symbol itself.

Thanks for the help

#include <stdio.h>
#include <stdlib.h>
#include "scan.h"
#define null 0

struct Names
{
struct Names *next;
struct Value *p_value;
struct Names *prev;
};

typedef struct Names DLList;
typedef struct Names header;
typedef struct header *headerpt;

struct Numbers
{
struct Numbers *next;
struct Value *p_value;
struct Numbers *prev;
};

typedef struct Numbers DLList;
typedef struct Numbers header;
typedef struct header *headerpt;

struct Separators
{
struct Separators *next;
struct Value *p_value;
struct Separators *prev;
};

typedef struct Separators DLList;
typedef struct Separators header;
typedef struct header *headerpt;

struct Uknown
{
struct Uknown *next;
struct Value *p_value;
struct Uknown *prev;
};

typedef struct Uknown DLList;
typedef struct Uknown header;
typedef struct header *headerpt;

struct Value
{
char Type;
int length;
char Value[256];
};

header *list(header *h, header *t)
{
h->prev=null;
h->next=t;
h->p_value=null;
t->prev=h;
t->next=null;
t->p_value=null;
return(h);
}

void append(header *l, DLList *obj)
{
DLList *q=l->next;
while(q->next != null)
q=q->next;
obj->prev=q->prev;
obj->next=q;
q->prev=obj;
q=obj->prev;
q->next=obj;
}

void printlist(header *pt)
{
DLList *q;
int i;
printf("\n->");
q=pt->next;
while(q->next != null)
{
i=q->p_value;
printf("%d->",i);
q=q->next;
}
printf("\n");
}

int main (int argc, char *argv[])
{
extern TKN get_token(FILE *);
TKN Token;
FILE *Input;
int Done = 0, k;
Input = fopen(argv[1], "r");
while (!Done)
{
Token = get_token( Input );
switch (Token.Code)
{
case 'I':
{
/* process identifier */
break;
}
case 'N':
{
/* process integer number */
break;
}
case 'F':
{
/* process real number */
break;
}
case 'W':
{
break;
}
case 'L':
{
break;
}
case 'U':
{
if (Token.String[0] == 'Z')
Done = 1;
else
break;
}
case 'O':
{
break;
}
}
} /* end while */
return 0;
}

Jan 30 '06 #1
1 3261
"Little" <co************@yahoo.com> writes:
Hello everyone. I am trying to do the following program and am unable
to get the beginning portion to work correctly. The scanner works when
I print the statements without the double linked list portion but I
just need help with the beginning portion with the double linked lists.

[snip]

You posted this same question (or nearly so) in this newsgroup on
January 22, January 24, January 26, and now again on January 30. You
also posted the same question to comp.lang.c.moderated (it just showed
up today). You have gotten a number of responses, and you have
acknowledged none of them.

Asking the same question again and again will not get you better
answers. If the responses you've already gotten aren't helpful, post
another followup *in the same thread* asking for clarification. Don't
start a new thread each time.

You're wasting our time.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
3
by: s_subbarayan | last post by:
Dear all, 1)In one of our implementation for an application we are supposed to collate two linked lists.The actual problem is like this: There are two singularly linked lists, the final output...
3
by: chellappa | last post by:
hi i create a c program ,which waas doing operation of linked list.......in single linked list it is working properly, but i want multiple linked list of same member... i am using array of...
3
by: Little | last post by:
Could someone help me get started on this program or where to look to get information, I am not sure how to put things together. 1. Create 4 double linked lists as follows: (a) A double linked...
1
by: Little | last post by:
Could someone help me figure out how to put my project together. I can't get my mind wrapped around the creation of the 4 double Linked Lists. Thank your for your insight. 1. Create 4 double...
3
by: Little | last post by:
Could someone tell me what I am doing wrong here about declaring mutiple double linked lists. This is what the information is for the project and the code wil be below that. Thank your soo much for...
4
by: FBM | last post by:
Hi, I am working on a program that simulates one of the elements of ATM. The simulation stores events which occurs every some milliseconds for a certain amount of time. Every time that an event...
2
by: PAzevedo | last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from multiple threads, now the Hashtable object is thread safe for reading, but not for writing, so I lock the object every time I...
9
by: Sheldon | last post by:
Hi, I am trying to understand linked lists and the different ways to write a linked list and double linked list. I have been trying to get this function called insert_word to work but to no...
6
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.