Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct lnode{
struct lnode *next;
int id;
char *name,*address;
char **phone;
};
/* twith pointer nextCategory we can browse the categories
i.e. family,freinds..
with pointer categSearch we can search the elements of
each category(basicaly with this pointer we can search
the linked list of each category)
*/
struct LinkLists{
struct LinkLists *nextCategory;
struct LinkLists *categSearch;
char *categName;
}
void createCategory(struct LinkLists **headRef,char *catgName);
int main (void){
char *category;
char buffer[81];
struct LinkLists *head=NULL;
printf("Give a category name to continue:\n");
printf("If you want to stop give an empty line.\n");
do{
scanf("%s",buffer);
category=(char *)malloc((strlen(buffer)+1)*sizeof(char));
if(!category){
fprintf(stderr,"Unable to allocate memory");
exit(1);
}
createCategory(&head,category);
}while(buffer[0]!='\n');
return 0;
}
void createCategory(struct LinkLists **headRef,char *catgName)
{
struct LinkLists *new;
struct LinkLists *current=*headRef;
struct LinkLists *prev;
new=(struct LinkLists *)malloc(sizeof(struct LinkLists ));
if(!new){
fprintf(stderr,"Unable to allocate memory");
exit(1);
}
if(*headRef==NULL){
new->nextCategory=*headRef;
*headRef=new;
new->categName=catgName;
}
else{
while(current!=NULL){
prev=current;
current=current->nextCategory;
}
prev->nextCategory=new;
new=current;
new->categName=catgName;
}
}
where is the problem? i take errors: two or more data types in declaration of `createCategory',
conflicting types for `createCategory.