0
#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??

Edited by Narue: Added code tags...not that it helped. :P

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by ravi543
0

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

0

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?

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.