#include<stdio.h>
#include<stdlib.h>
typedef struct a
{
int data;
struct a* next;
}node;
void addatbeg();
void delete();
void display();
node *first=NULL;
int main()
{
int ch;
while(1)
{
printf("\n1:to add elements \n2:to delete elements\n 3:to display elements");
scanf("%d",&ch);
switch(ch)
{
case 1:addatbeg();
break;
case 2:delete();
break;
case 3:display();
break;
default:printf("\n invalid option");
}
}
}
void addatbeg()
{
node *new;
int ele;
new=(node*)malloc(sizeof(node));
new->next=first;
first=new;
printf("enter the element");
scanf("%d",&ele);
new->data=ele;
}
void display()
{
node *temp;
temp=first;
while(temp!=NULL)
{
printf("%d->",temp->data);
temp=temp->next;
}
}
void delete()
{
int pos,i;
node *temp=first;
node* prev=NULL;
printf("\n enter the positon to delete");
scanf("%d",&pos);
if(pos==1)
first=first->next;
else
{
for(i=0;i<pos-1;i++)
{ prev=temp;
temp=temp->next;
}
prev->next=temp->next;
}
}
when i run the above program in pelles c i get the following messages:
C:\Documents and Settings\Administrator\My Documents\Pelles C Projects\array\main.c(39): warning #2027: Missing prototype for 'addatbeg'.
C:\Documents and Settings\Administrator\My Documents\Pelles C Projects\array\main.c(55): warning #2027: Missing prototype for 'display'.
C:\Documents and Settings\Administrator\My Documents\Pelles C Projects\array\main.c(65): warning #2027: Missing prototype for 'delete'.
but all prototypes are included at the beginning.