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

Mlutiple Linked list Array

hi Everybody!
i am trying multiple array linked list .. i am trying , but its give
derefernceing pointer to incompelete type .. please help me to correct
this pgm

#include<stdlib.h>
#include<stdio.h>
void insert(int listno,int value);
struct listl {
int val;
struct list * next;
};

typedef struct list item;
item * curr[10], * head[10];

int main(void) {
int i;

for(i=0;i<=9;i++)
{
head[i] = NULL;
}

insert(2,21);
insert(2,2);
insert(2,5);
insert(7,54);
insert(7,45);
insert(7,75);
curr[2] = head[2];
curr[7] = head[7];
while(curr[2]&&curr[7])
{
printf("%d\n%d\n", curr[2]->val,curr[7]->val);
curr[2] = curr[2]->next ;
curr[7] = curr[7]->next ;

}
}
void insert (int listno,int value)
{
curr[listno] = (item *)malloc(sizeof(item));
curr[listno]->val = value;
curr[listno]->next = head[listno];
head[listno] = curr[listno];
}

Thnank u
by
CNS

Nov 15 '05 #1
2 1210
hi,
Error is on line no. 4
it should be "struct list {"
bye
ssj

Nov 15 '05 #2

chellappa wrote:
...
#include<stdlib.h>
#include<stdio.h>
...
curr[listno] = (item *)malloc(sizeof(item));


don't cast the return of malloc. void* converts to other pointer types
implicitly just fine. A cast could hide the error of you forgetting to
include stdlib.h, if you did forget that. don't cast unnecessarily.

Nov 15 '05 #3

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

Similar topics

5
by: Jeffrey Silverman | last post by:
Hi, all. I have a linked list. I need an algorithm to create a tree structure from that list. Basically, I want to turn this: $list = array( array( 'id' => 'A', 'parent_id' => null, 'value'...
9
by: Goh, Yong Kwang | last post by:
I'm currently doing a project that has a array that supposed to be determined only at runtime. Originally, the prototype I did as a proof of theory (or a quick hack) So one method is to create a...
3
by: picknicker187 | last post by:
hi, the program below is supposed to read data out of a txt file into an array and the second part of the data to a linked list. 8 is the number of words, the 10 terms below represent...
12
by: Eugen J. Sobchenko | last post by:
Hi! I'm writing function which swaps two arbitrary elements of double-linked list. References to the next element of list must be unique or NULL (even during swap procedure), the same condition...
8
by: MJ | last post by:
Hi I have a question I have a singly linked list of 10 elements. I have to find the Nth (Ex 3rd element from the end) element from the end. What are the ways to do it with less complexity I...
32
by: Clunixchit | last post by:
How can i read lines of a file and place each line read in an array? for exemple; array=line1 array=line2 ...
19
by: Tom Jastrzebski | last post by:
Hello, I was just testing VB.Net on Framework.Net 2.0 performance when I run into the this problem. This trivial code attached below executed hundreds, if not thousand times faster in VB 6.0...
11
by: skumar434 | last post by:
Hi everybody, I am faceing problem while assigning the memory dynamically to a array of structures . Suppose I have a structure typedef struct hom_id{ int32_t nod_de; int32_t hom_id;
36
by: pereges | last post by:
Hi, I am wondering which of the two data structures (link list or array) would be better in my situation. I have to create a list of rays for my ray tracing program. the data structure of ray...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.