473,396 Members | 1,998 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,396 software developers and data experts.

linked list problem

It's been a while since I programmed in C, and I'm confused as to why I get
the following error message (why aren't they both "pointer to struct
chromT{}"?:

"genet.c", line 192: warning: assignment type mismatch:
pointer to struct {double score, enum {worst(2), mid(1), best(0)}
cat, array[10] of pointer to struct geneT {..} genes, pointer to struct
chromT {..} next} "=" pointer to struct chromT {}

my code is as follows (I have noted the line with the problem):

// DATA STRUCTURES

typedef struct {
double score;
categ cat;
struct geneT *genes[GENES_PER_CHROM];
struct chromT *next;
} chromT;

typedef struct {
double x[PTS_PER_FEAT];
double id; // something to keep track of each feature.
} geneT;
// FUNCTION PROTOTYPES
static void *LLGo (chromT *start, int n);

/* LLGo
*
* This function returns the address of the "n-th" element
* in the linked list.
*/
static void *LLGo (chromT *start, int n) {
int i = 0;
chromT *cursor = start;

while((cursor->next != NULL) && (i < n)) {
cursor = cursor->next; // THIS IS THE LINE WITH THE PROBLEM
i++;
}
if(i < n) {
return NULL;
}
else {
return cursor;
}
}
Nov 13 '05 #1
2 2767
In article <bo**********@news.Stanford.EDU>,
Darius Fatakia <da************@yahoo.com> wrote:
It's been a while since I programmed in C, and I'm confused as to why I get
the following error message (why aren't they both "pointer to struct
chromT{}"?:

"genet.c", line 192: warning: assignment type mismatch:
pointer to struct {double score, enum {worst(2), mid(1), best(0)}
cat, array[10] of pointer to struct geneT {..} genes, pointer to struct
chromT {..} next} "=" pointer to struct chromT {}

my code is as follows (I have noted the line with the problem):

// DATA STRUCTURES

typedef struct {
double score;
categ cat;
struct geneT *genes[GENES_PER_CHROM];
struct chromT *next;
} chromT;

typedef struct {
double x[PTS_PER_FEAT];
double id; // something to keep track of each feature.
} geneT;


In the first typedef:

you refer to "struct geneT", but you haven't defined a "struct geneT".
you refer to "struct chromT", but you haven't defined a "struct chromT".

Try this:

typedef struct {
double x[PTS_PER_FEAT];
double id; // something to keep track of each feature.
} geneT;

typedef struct chromT { // note: struct chromT
double score;
categ cat;
geneT *genes[GENES_PER_CHROM]; // note: "geneT", not "struct geneT"
struct chromT *next;
} chromT;
--
Rouben Rostamian <ro*******@umbc.edu>
Nov 13 '05 #2
Thanks!!!
Nov 13 '05 #3

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

Similar topics

19
by: RAJASEKHAR KONDABALA | last post by:
Hi, Does anybody know what the fastest way is to "search for a value in a singly-linked list from its tail" as oposed to its head? I am talking about a non-circular singly-linked list, i.e.,...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
7
by: Kieran Simkin | last post by:
Hi all, I'm having some trouble with a linked list function and was wondering if anyone could shed any light on it. Basically I have a singly-linked list which stores pid numbers of a process's...
10
by: Ben | last post by:
Hi, I am a newbie with C and am trying to get a simple linked list working for my program. The structure of each linked list stores the char *data and *next referencing to the next link. The...
57
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
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...
11
by: bofh1234 | last post by:
Hello, I am having a problem with linked lists. My program is based on a client server model. The client sends some packets of data to the server. The server reads those packets and is...
22
by: joshc | last post by:
In an interview for an embedded software position recently I was asked to write code, in C, for printing the contents of a linked list backwards. After a few minutes I came up with the recursive...
23
by: Himanshu Chauhan | last post by:
Hi! I was wondering, In the first parse of a singly linked list of unknown length, is it possible to know when we are at middle of the linked list? Regards --Himanshu
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.