In the following code I get the error ' freespace: function must return a value' . Could you tell me what's wrong?. Thanks
Code:
#include <stdio.h>
#include <string.h>
int freespace(char name[][20],int pos_pntr);
int add_contact(char name[][20],char company[][20],int phone_number[],int pos_pntr);
void main(void)
{
char name[10][20];
char company[10][20];
int phone_number[10];
int pos_pntr=0;
pos_pntr=freespace(name,pos_pntr);
pos_pntr=add_contact(name,company,phone_number,pos_pntr);
}
int freespace(char name[][20],int pos_pntr)
{
int count=0,i;
for(i=0;i<10;i++)
{
strcpy(name[i], NULL);
}
for(i=0;i<10;i++)
{
if(name[i]== NULL)
{
count++;
}
if(count==0)
{
i=20;
return pos_pntr;
}
else
{
printf("No Free sapce left");
return;
}
}
pos_pntr++;
}
int add_contact(char name[][20],char company[][20],int phone_number[],int pos_pntr)
{
puts("Enter the name fo the contact:-");
gets(name[pos_pntr]);
puts("Enter the company name:-");
gets(company[pos_pntr]);
puts("Enter the phone number:-");
scanf("%d",&phone_number[pos_pntr]);
pos_pntr++;
return pos_pntr;
}
[code][/code]tagged by Salem