:evil: The following C program is mainly written to work as an address book. I have written the code but the VC++ compiler shows four errors and I cant find them :rolleyes: . Can some one please help me find them..my assignment deadline line is on the 10th of this month.

//initializing the header files

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

//defining the properties of the fields used in the program

#define NAME 50
#define ADDRESS 8
#define PHONE 20
#define EMAIL 20
#define SIZE 500

//declaring the functions

void Insert();
void Del_info();
void Display();
void Search();
void Exit();

char info[SIZE];

//using structures that represent the fields in the program

struct addressbook
{
char name [NAME] ;
char address [ADDRESS];
char phone [PHONE];
char email [EMAIL] ;
char Target[NAME];

} addressbook;

//initializing the files used in the program

FILE *AddressBook;
FILE *rectemp;

int main()
{		
	    int choice=0;
		int k;
        printf("                           Welcome \n");
        printf("                           Address Book\n"); 
        printf("                 This program is licensed to Kashfee\n");
	    printf("Please enter the password(an integer): ");
	    scanf("%d",&k);
	if (k!=8912685)
	{
		printf("Password Invalid\n");
		return 0;
	}
	
	else{
		printf("\n My Address Book can perform the following operations \t");
		printf("\n 1> Insert new Entry\n");
		printf("\n 2> Delete Entry\n");
		printf("\n 3> Display all Entry\n");
		printf("\n 4> Search Entry\n");
		printf("\n 5> Exit the program\n");
		printf("\n Enter your choice <1-5>: ");
		scanf("%i",&choice);

 switch (choice)
	{	
	
			case 1:
				{
				Insert(); 
				break;
				}

			case 2:
				{
				Del_info();
				break;
				}
			
			case 3:
				{	
				Display();
				break;
				}

			case 4:
				{	
				Search();	
				break;
				}

		case 5:
			{
				Exit();
				break;
			}


		default:
			{
				
				printf("**Invalid Input.**\n");
				
			}


	}
	}
}
void Insert()
{
	char choice1;
    do
	{		//opening the AddressBook file
			AddressBook = fopen("AddressBook.txt","a+");

				
			printf("Enter Person's Name\n");
			scanf("%s",addressbook.name);
			

			printf("Enter Person's Address\n");
			scanf("%s",addressbook.address);
			
            printf("Enter Person's Phone no.\n");
			scanf("%s",addressbook.phone);
			

			printf("Enter Person's E-mail\n");
			scanf("%s",addressbook.email);
			
					
			//printing all the entries to the main file (AddressBook.txt)
			fprintf(AddressBook,"%s %s %s %s  \n",addressbook.name,addressbook.address,addressbook.phone,addressbook.email);
			fclose(AddressBook);
		
		
			
		//initializing the choice character to give an option to continue
			printf("Press y/Y to Execute the Program Again \n");
			scanf("%c",&choice1);
			
		
	}
	while(choice1=='y'||choice1=='Y');
	main();
}

void Del_info()
{
	char choice2;
	char Target[SIZE];
	int Found=0;
    rectemp=fopen("rectemp.txt","w");
	if((AddressBook=fopen("AddressBook.txt","r"))==NULL)
		printf("**The File is Empty**\n\n");

	else{
							printf("\tEnter Person's Name : ");
							gets(Target);
	
			while(!feof(AddressBook))
			{
			fscanf(AddressBook,"%s %s %s %s",addressbook.name,addressbook.address,addressbook.phone,addressbook.email);
			if(feof(AddressBook))
			break;
		   if(strcmp(Target,addressbook.name)!=0)
			
			fprintf(rectemp,"%s %s %s %s \n",addressbook.name,addressbook.address,addressbook.phone,addressbook.email);
						else {
		
							Found=1;
							}
			if (!Found)
			{
			printf("\t**There is no such Entry\n");//incase no files are located
			}
		printf("\t**Item is Deleted**\n");
		
		fclose(AddressBook);
		fclose(rectemp);
		remove("Addressbook.txt");
		
		rename("rectemp.txt","AddressBook.txt");
					
		do{
            printf("Press y/Y to Execute the Program Again \n");
			scanf("%c",&choice2);			
		
		}
		while(choice2=='y'||choice2=='Y');
		main();

	
}

void Display()
{
       char choice3;

		AddresssBook = fopen("AddressBook.txt","a+");
		do
		{

			fgets(info,SIZE,AddressBook);
			printf("%s\n",info);

		}while(!feof(AddressBook));
			fclose(AddressBook);
			do{
            printf("Press y/Y to Execute the Program Again \n");
			scanf("%c",&choice3);
			
		
	}while(choice3=='y'||choice3=='Y');

			main();
}

void Search()
{
	char choice4;	
	char Target[SIZE];
	int Found=0;
	if((AddressBook=fopen("AddressBook.txt","r"))==NULL)
	
				printf("**The file is empty** !!\n\n");
	else
	{
     printf("\tEnter The Name:");
							
	scanf("%s",Target);
	while(!feof(Address)&& Found==0)
	{
	fscanf(AddressBook,"%s %s %s %s ",addressbook.name,addressbook.address,addressbook.phone,addressbk.email);
	if(strcmp(Target,addressbook.name)==0)
	Found=1;
	}
	if(Found)
	{
	printf("The Name is:          %s\n",addressbook.name);
	printf("The address is:       %s\n",addressbook.address);
	printf("The phone number is:  %s\n",addressbook.phone);
	printf("The e-mail address is:%s\n",addressbook.email);
	
	main();
	}
	else if(!Found)
		printf("**There is no such Entry**\n");
	fclose(Addressbook);
	}
	do{
		printf("Press y/Y to Execute the Program Again \n");
		scanf("%c",&choice4);
			
		
	}
	while(choice4=='y'||choice4=='Y');
	main();
}


void Exit()
{
printf("**********************\n");
}

The list of things you've done wrong is too long for me to go into detail, so here are the biggies:

1) gets is wrong
2) main should not be called recursively
3) feof is not meant to be a loop condition
4) Your constructs are very inconsistent

At least you didn't use void main. Here is the code that compiles:

//initializing the header files

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

//defining the properties of the fields used in the program

#define NAME 50
#define ADDRESS 8
#define PHONE 20
#define EMAIL 20
#define SIZE 500

//declaring the functions

void Insert();
void Del_info();
void Display();
void Search();
void Exit();

char info[SIZE];

//using structures that represent the fields in the program

struct addressbook
{
  char name [NAME] ;
  char address [ADDRESS];
  char phone [PHONE];
  char email [EMAIL] ;
  char Target[NAME];
} addressbook;

//initializing the files used in the program

FILE *AddressBook;
FILE *rectemp;

int main()
{		
  int choice=0;
  int k;
  printf("                           Welcome \n");
  printf("                           Address Book\n"); 
  printf("                 This program is licensed to Kashfee\n");
  printf("Please enter the password(an integer): ");
  scanf("%d",&k);
  if (k!=8912685)
  {
    printf("Password Invalid\n");
    return 0;
  }
  else{
    printf("\n My Address Book can perform the following operations \t");
    printf("\n 1> Insert new Entry\n");
    printf("\n 2> Delete Entry\n");
    printf("\n 3> Display all Entry\n");
    printf("\n 4> Search Entry\n");
    printf("\n 5> Exit the program\n");
    printf("\n Enter your choice <1-5>: ");
    scanf("%i",&choice);

    switch (choice)
    {	
    case 1:
      {
        Insert(); 
        break;
      }
    case 2:
      {
        Del_info();
        break;
      }
    case 3:
      {	
        Display();
        break;
      }
    case 4:
      {	
        Search();	
        break;
      }
    case 5:
      {
        Exit();
        break;
      }
    default:
      {
        printf("**Invalid Input.**\n");
      }
    }
  }
}
void Insert()
{
  char choice1;
  do
  {		//opening the AddressBook file
    AddressBook = fopen("AddressBook.txt","a+");

    printf("Enter Person's Name\n");
    scanf("%s",addressbook.name);

    printf("Enter Person's Address\n");
    scanf("%s",addressbook.address);

    printf("Enter Person's Phone no.\n");
    scanf("%s",addressbook.phone);

    printf("Enter Person's E-mail\n");
    scanf("%s",addressbook.email);

    //printing all the entries to the main file (AddressBook.txt)
    fprintf(AddressBook,"%s %s %s %s  \n",addressbook.name,addressbook.address,addressbook.phone,addressbook.email);
    fclose(AddressBook);

    //initializing the choice character to give an option to continue
    printf("Press y/Y to Execute the Program Again \n");
    scanf("%c",&choice1);
  }
  while(choice1=='y'||choice1=='Y');
  main();
}

void Del_info()
{
  char choice2;
  char Target[SIZE];
  int Found=0;
  rectemp=fopen("rectemp.txt","w");
  if((AddressBook=fopen("AddressBook.txt","r"))==NULL)
    printf("**The File is Empty**\n\n");
  else{
    printf("\tEnter Person's Name : ");
    gets(Target);

    while(!feof(AddressBook))
    {
      fscanf(AddressBook,"%s %s %s %s",addressbook.name,addressbook.address,addressbook.phone,addressbook.email);
      if(feof(AddressBook))
        break;
      if(strcmp(Target,addressbook.name)!=0)
        fprintf(rectemp,"%s %s %s %s \n",addressbook.name,addressbook.address,addressbook.phone,addressbook.email);
      else {
        Found=1;
      }
      if (!Found)
      {
        printf("\t**There is no such Entry\n");//incase no files are located
      }
      printf("\t**Item is Deleted**\n");

      fclose(AddressBook);
      fclose(rectemp);
      remove("Addressbook.txt");

      rename("rectemp.txt","AddressBook.txt");

      do{
        printf("Press y/Y to Execute the Program Again \n");
        scanf("%c",&choice2);			
      }
      while(choice2=='y'||choice2=='Y');
      main();
    }
  }
}

void Display()
{
  char choice3;

  AddressBook = fopen("AddressBook.txt","a+");
  do
  {
    fgets(info,SIZE,AddressBook);
    printf("%s\n",info);
  }while(!feof(AddressBook));
  fclose(AddressBook);
  do{
    printf("Press y/Y to Execute the Program Again \n");
    scanf("%c",&choice3);


  }while(choice3=='y'||choice3=='Y');

  main();
}

void Search()
{
  char choice4;	
  char Target[SIZE];
  int Found=0;
  if((AddressBook=fopen("AddressBook.txt","r"))==NULL)

    printf("**The file is empty** !!\n\n");
  else
  {
    printf("\tEnter The Name:");

    scanf("%s",Target);
    while(!feof(AddressBook)&& Found==0)
    {
      fscanf(AddressBook,"%s %s %s %s ",addressbook.name,addressbook.address,addressbook.phone,addressbook.email);
      if(strcmp(Target,addressbook.name)==0)
        Found=1;
    }
    if(Found)
    {
      printf("The Name is:          %s\n",addressbook.name);
      printf("The address is:       %s\n",addressbook.address);
      printf("The phone number is:  %s\n",addressbook.phone);
      printf("The e-mail address is:%s\n",addressbook.email);

      main();
    }
    else if(!Found)
      printf("**There is no such Entry**\n");
    fclose(AddressBook);
  }
  do{
    printf("Press y/Y to Execute the Program Again \n");
    scanf("%c",&choice4);
  }
  while(choice4=='y'||choice4=='Y');
  main();
}


void Exit()
{
  printf("**********************\n");
}

Thank you so much...your suggestions really helped :D

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.