C
cpptutor2000
I am trying to create a simple linked list. The source code is provided
below. I receive the following error message: (Please see after source
code). I have marked the lines where the error occurs with three '***'.
#include "palmvector.h"
struct palmvectornode{
char ch;
struct palmvectornode *next;
};
void add(char ch){
struct palmvectornode *temp = NULL;
void * tmp = NULL;
if(start == NULL){
temp = (struct palmvectornode*)malloc(sizeof(struct
palmvectornode));
temp->ch = ch;
temp->next = NULL;
(struct palmvectornode*)start = (struct
palmvectornode*)temp;
(struct palmvectornode*)currpos = (struct
palmvectornode*)temp;
return;
}
if(start != NULL){
temp = (struct palmvectornode*)malloc(sizeof(struct
palmvectornode));
temp->ch = ch;
temp->next = NULL;
*** currpos->next = (struct palmvectornode *)temp;
(struct palmvectornode*)currpos = (struct
palmvectornode*)temp;
return;
}
}
unsigned int found(char chf){
struct palmvectornode* temp = (struct palmvectornode*)start;
while(temp != NULL){
if(temp->ch == chf){
return 1;
}
temp = temp->next;
}
return 0;
}
void deletepalmvector(){
struct palmvectornode *temp = (struct palmvectornode*)start;
while(start != NULL){
start = (struct palmvectornode*)start->next;
free(temp);
*** (struct palmvectornode*)temp = (struct
palmvectornode*)start;
}
}
.../src/palmvector.c: In function `add':
.../src/palmvector.c:25: error: dereferencing pointer to incomplete type
.../src/palmvector.c: In function `deletepalmvector':
.../src/palmvector.c:47: error: dereferencing pointer to incomplete type
Could someone please point out what might be wrong? THanks in advance
for
your help. I am using GCC 3.3.1 as packeaged in the Palm OS Developer
Suite.
below. I receive the following error message: (Please see after source
code). I have marked the lines where the error occurs with three '***'.
#include "palmvector.h"
struct palmvectornode{
char ch;
struct palmvectornode *next;
};
void add(char ch){
struct palmvectornode *temp = NULL;
void * tmp = NULL;
if(start == NULL){
temp = (struct palmvectornode*)malloc(sizeof(struct
palmvectornode));
temp->ch = ch;
temp->next = NULL;
(struct palmvectornode*)start = (struct
palmvectornode*)temp;
(struct palmvectornode*)currpos = (struct
palmvectornode*)temp;
return;
}
if(start != NULL){
temp = (struct palmvectornode*)malloc(sizeof(struct
palmvectornode));
temp->ch = ch;
temp->next = NULL;
*** currpos->next = (struct palmvectornode *)temp;
(struct palmvectornode*)currpos = (struct
palmvectornode*)temp;
return;
}
}
unsigned int found(char chf){
struct palmvectornode* temp = (struct palmvectornode*)start;
while(temp != NULL){
if(temp->ch == chf){
return 1;
}
temp = temp->next;
}
return 0;
}
void deletepalmvector(){
struct palmvectornode *temp = (struct palmvectornode*)start;
while(start != NULL){
start = (struct palmvectornode*)start->next;
free(temp);
*** (struct palmvectornode*)temp = (struct
palmvectornode*)start;
}
}
.../src/palmvector.c: In function `add':
.../src/palmvector.c:25: error: dereferencing pointer to incomplete type
.../src/palmvector.c: In function `deletepalmvector':
.../src/palmvector.c:47: error: dereferencing pointer to incomplete type
Could someone please point out what might be wrong? THanks in advance
for
your help. I am using GCC 3.3.1 as packeaged in the Palm OS Developer
Suite.