Advertisement

05.07.2008 at 06:56AM PDT, ID: 23382745
[x]
Attachment Details

linked list problem

Asked by pothios in C Programming Language

Tags: c

hi, i realise that when  dlist does the calloc, it returns a bad pointer and program will fail at strcpy. someone please tell me wat is wrong here? thanksStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
struct dList {
	char* type;
	char* point;
	int id;
	char* name;
	struct dList *next;
};
 
struct dList *dHead = (struct dList*) NULL;
struct dList *dEnd = (struct dList*) NULL;
 
struct dList* add(char* type, int id, char* point, char* name) {
	struct dList *list;
	list = (struct dList*)calloc(1, sizeof(struct dList));
	if(dlist == NULL) {
		return (struct dList*)NULL;
	} else {
		strcpy(list->type, type);
		list->id = id;
		strcpy(list->point, point);
		strcpy(list->name, name);
		return list ;
	}
}
[+][-]05.07.2008 at 07:01AM PDT, ID: 21516436

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.07.2008 at 07:01AM PDT, ID: 21516440

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C Programming Language
Tags: c
Sign Up Now!
Solution Provided By: Infinity08
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.07.2008 at 07:07AM PDT, ID: 21516497

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.07.2008 at 07:10AM PDT, ID: 21516521

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628