conflicting types

well, i have this code...
i have tried to run it but the compiler tells me that there are conflicting types in my code...
this code is not yet finished.

HELP!!!


#include<stdio.h>
#include<string.h>

#define max 20

typedef struct s_tag{
char name[50];
long mobilenum;
} contact;

void menu(contact c_array[]){
int option;
do{
printf("----------\n");
printf("Functionalities:\n");
printf("----------\n");
printf("[1] Add contact\n[2] Edit contact\n[3] Delete All contact\n[4] View All contact\n[5] Exit\n");
printf("Enter option: \n");
scanf("%d", &option);
switch(option){
case 1:
add(c_array);
break;
case 2:
edit(c_array);
break;
case 3:
deleteall(c_array);
break;
case 4:
viewall(c_array);
break;
default:
return;
}
}while(option!=5);
}

void add(contact c_array[]){
int i;
for(i=0;i<max;i++){
printf("Enter name: ");
scanf("%s",c_array[i].name);
printf("Enter phone number: ");
scanf("%li",&(c_array[i].mobilenum));
}

void edit(contact c_array[]){
int y,i,j;
printf("Enter mobile number you want to change: \n");
scanf("%d", &j);

for(i=0;i<max;i++){
if(j==c_array[i].mobilenum){
printf("Enter the information you want to edit.\n");
printf("[0] Name\n[1] Phone Number\n");
scanf("%d",&y);

if(y==0){
printf("Enter new Name: \n");
scanf("%s",c_array[i].name);
}
else if(y==1){
printf("Enter new Phone Number: \n");
scanf("%s",&(c_array[i].mobilenum));
}
}
}
}

int main(){
contact c_array[max];
menu(c_array);
return;
}
Hi ,
I have made some changes in the code
you have to write delete all function and viewall function , now this should work .
please follow the proper indents .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include<stdio.h>
#include<string.h>

#define max 20
typedef struct s_tag{
	char name[50];
	long mobilenum;
	} contact;

void add(contact c_array[]);
void menu(contact c_array[]);
void edit(contact c_array[]);

void menu(contact c_array[])
{
	int option;
	do{
		printf("----------\n");
		printf("Functionalities:\n");
		printf("----------\n");
		printf("[1] Add contact\n[2] Edit contact\n[3] Delete All contact\n[4] View All contact\n[5] Exit\n");
		printf("Enter option: \n");
		scanf("%d", &option);
		switch(option)
		{
		case 1:
				add(c_array);
				break;
		case 2:
				edit(c_array);
				break;
		case 3:
				deleteall(c_array);
				break;
		case 4:
				viewall(c_array);
				break;
		default:
				return;	
		}
	}while(option!=5);
}

void add(contact c_array[])
{
		int i;
		for(i=0;i<max;i++)
		{
			printf("Enter name: ");
			scanf("%s",c_array[i].name);
			printf("Enter phone number: ");
			scanf("%li",&(c_array[i].mobilenum));
		}
}

void edit(contact c_array[])
{
		int y,i,j;
		printf("Enter mobile number you want to change: \n");
		scanf("%d", &j);

		for(i=0;i<max;i++)
		{
			if(j==c_array[i].mobilenum)
			{
				printf("Enter the information you want to edit.\n");
				printf("[0] Name\n[1] Phone Number\n");
				scanf("%d",&y);

				if(y==0)
				{
					printf("Enter new Name: \n");
					scanf("%s",c_array[i].name);
				}
				else if(y==1)
				{
					printf("Enter new Phone Number: \n");
					scanf("%s",&(c_array[i].mobilenum));
				}
			}
	}
}
int _tmain(int argc, _TCHAR* argv[])
{
	contact c_array[max];
	menu(c_array);
	return 0;
}
Topic archived. No new replies allowed.