#include<stdio.h>
#include<malloc.h>
struct node{
int info;
struct node *link;
}*start;

void main(){
start=NULL;
int n,i,el;
printf("Enter the no. of elements u want 2 enter");
scanf("%d",&n);
for(i=0;i<n;i++){
 scanf("%d",&el);
createlist(el);
}

void createlist(int data){
 struct node *q,*tmp;
  tmp->info=data;
tmp->link=NULL;
if(start==NULL)
  start=tmp;
else
{q =start;
   while(q->link!=NULL)
       q=q->link;
  q->link=tmp;
}

}

struct node *q;
 if(start==NULL)
  { printf("list is empty");
      return;}

q=start;
printf("Lidt is :\n");
while(q!=NULL)
{ printf("%d",q->info);
    q=q->link;

}
printf("\n");

}

when i am running this program i am getting an error: In function main undefined reference to createlist. can anyone help me out??

Recommended Answers

The function needs to be declared before its first use either with a prototype or by placing the definition prior to main().

Jump to Post

All 4 Replies

The function needs to be declared before its first use either with a prototype or by placing the definition prior to main().

What kind of program is this?

After looking more and more at your code, you have createList() function inside main()??? The for-loop in the main has an open curly bracket and only close once?

hey!! thanks friends and thanks to Taywin. you people helped me to figured it out.still there is a problem. i will let u know after a little time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.