i want do this pro that looks like phone index
but i have problems
and i dunno how to fix this

its console application - c++ source file

plz help me quikly

#include<iostream.h>
void main()
{
	char names[10],n;
	double tel[10],tel1;
	int x,i,f=0,f1=0;
	cout<<"1 - add new rec"<<endl;
	cout<<"2 - search by tel"<<endl;
	cout<<"3 - search by name"<<endl;
	cout<<"4 - Exit"<<endl;
	cin>>x;
	switch(x)
	{
	case 1: addrec;break;
	case 2: sertel;break;
	case 3: sername;break;
	case 4: exit;
	default : cout<<"Error";break;
	}
	void addrec()
	{
		for(i=0;i<10;i++)
		{
			cout<<"Enter Name"<<endl;
			cin>>name[i];
			cout<<"Enter tel"<<endl;
			cin>>tel[i];
		}
	}
	void sertel()
	{
		cout<<"Enter tel you want search"<<endl;
		cin>>tel1;
		for(i=0;i<=9;i++)
			if tel1==tel[i]
			{cout<<name[i]<<endl;
			f=1;
			}
			if f==0;cout<<"Not found"<<endl;
	}
	void sername()
	{
		cout<<"Enter name"<<endl;
		cin>>n;
		for(i=o;i<=9;i++)
			if n==name[i]
			{
				cout<<te;[i]<<endl;
				f1=1;
			}
			if(f1==0)cout<<"Not found"<<endl;
	}
}

case 1: addrec;break;
case 2: sertel;break;
case 3: sername;break;

they supposed to be written like this sertel();

- #include <iostream.h> should be #include <iostream> .
- void main() should be int main (void) That's the way it's defined. You also need to add a return 0; when your program is done
-You need to declare the functions before using them (for example: add void addrec(void); before main() )
- what atish00 said: functions are called with braces ()
- cin>>name[i]; should be cin>>names[i]; , just a typo.

that's what I see at first look, so there are probably more errors. Next time when you post your code, also post the compiler errors, this makes it easier to find errors.

[edit] You also need to take a second look at some of your if-statements, there are some syntaxerrors

The functions are not properly defined. All functions sername(), sertel(), addrec(). Must have an argument of an array type.

For example.
addrec(char[], double[])

I dont think you have made this program yourself.

thank you for your help
but it didnt work :(

here you are the errors :

error C2065: 'addrec' : undeclared identifier
error C2065: 'sertel' : undeclared identifier
error C2065: 'sername' : undeclared identifier
error C2065: 'exit' : undeclared identifier
error C2373: 'addrec' : redefinition; different type modifiers
error C2601: 'addrec' : local function definitions are illegal
error C2373: 'sertel' : redefinition; different type modifiers
error C2601: 'sertel' : local function definitions are illegal
error C2373: 'sername' : redefinition; different type modifiers
error C2601: 'sername' : local function definitions are illegal


help me :(

i made it my self

why do u think i didnt :(

i'm new in c++ :(

Post your new code.
There are *a lot* of other things wrong with your code which I didn't mention in my previous post, but we'll take it a step at a time ;)

this is the code

#include<iostream.h>
void main()
{
	char names[10],n;
	double tel[10],tel1;
	int x,i,f=0,f1=0;
	cout<<"1 - add new rec"<<endl;
	cout<<"2 - search by tel"<<endl;
	cout<<"3 - search by name"<<endl;
	cout<<"4 - Exit"<<endl;
	cin>>x;
	switch(x)
	{
	case 1: addrec;break;
	case 2: sertel;break;
	case 3: sername;break;
	case 4: exit;
	default : cout<<"Error";break;
	}
	void addrec()
	{
		for(i=0;i<10;i++)
		{
			cout<<"Enter Name"<<endl;
			cin>>name[i];
			cout<<"Enter tel"<<endl;
			cin>>tel[i];
		}
	}
	void sertel()
	{
		cout<<"Enter tel you want search"<<endl;
		cin>>tel1;
		for(i=0;i<=9;i++)
			if tel1==tel[i]
			{cout<<name[i]<<endl;
			f=1;
			}
			if f==0;cout<<"Not found"<<endl;
	}
	void sername()
	{
		cout<<"Enter name"<<endl;
		cin>>n;
		for(i=o;i<=9;i++)
			if n==name[i]
			{
				cout<<tel;[i]<<endl;
				f1=1;
			}
			if(f1==0)cout<<"Not found"<<endl;
	}
}

and this is the errors

error C2065: 'addrec' : undeclared identifier
error C2065: 'sertel' : undeclared identifier
error C2065: 'sername' : undeclared identifier
error C2065: 'exit' : undeclared identifier
error C2373: 'addrec' : redefinition; different type modifiers
error C2601: 'addrec' : local function definitions are illegal
error C2373: 'sertel' : redefinition; different type modifiers
error C2601: 'sertel' : local function definitions are illegal
error C2373: 'sername' : redefinition; different type modifiers
error C2601: 'sername' : local function definitions are illegal

So you haven't changed a thing? Change the things I already mentioned.

Some stuff you should know about functions

Please read it and then compare it with what you have done yourself.
Here's an example of how to use a function:

#include <iostream>

using namespace std;

int mult ( int x, int y );

int main()
{
  int x;
  int y;
  
  cout<<"Please input two numbers to be multiplied: ";
  cin>> x >> y;
  cin.ignore();
  cout<<"The product of your two numbers is "<< mult ( x, y ) <<"\n";
  cin.get();
}

int mult ( int x, int y )
{
  return x * y;
}

In the cases write function as function() .... PUT THE BRACKETS.

If you made the code yourself then I am sorry. You have to start with the basics of functions like niek_e said.

Additionaly read about the syntax of if statements and strings.

I think what you are trying to do is accept 10 names and their corresponding phone numbers. But the declaration

char names[10]

will accept only one string i.e one name.

Be a part of the DaniWeb community

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