Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I AM GETTING A SYNTAX ERROR ON LINE 340 WHICH IS THE VERY LAST LINE OF THE CODE

ID: 3538889 • Letter: I

Question

I AM GETTING A SYNTAX ERROR ON LINE 340 WHICH IS THE VERY LAST LINE OF THE CODE ... CAN SOMEONE PLEASE FIX THIS SO I CAN TURN IT IN ....HELLLLLLLLLLLLLPPPPPPP!!!!!!!!


BELOW IS MY CODE





//Include library files to handle the functions in source code


#include <stdio.h>

#include <string.h>


/* -------- DECLARE ALL STRUCTURES HERE -------- */

typedef struct Phonebook_Contacts

{

char FirstName[20]; //Entered First Name

char LastName[20]; //Entered Last Name

char PhoneNumber[20]; //Phone Number

} phone; //TypeDef to Modify structure name

/* -------- DECLARE ALL FUNCTION PROTOTYPES HERE -------- */

void AddEntry(phone * ); //Function prototype to Add Entries

void DeleteEntry(phone * ); //Function prototype to Delete Entries

void PrintEntry(phone * ); //Function prototype to Display Entries

void SortByFirstName(phone * ); //Function prototype to Sort Contacts by First Name

void SortByLastName(phone * ); //Function prototype to Sort Contacts by Last Name

void SearchForNumber(phone * ); //Function prototype to Search for Specific Number by Name

void RandomName(phone * ); //Function prototype to get a Random Friend

void DeleteAll(phone * ); //Function prototype to Delete All Contacts


/* -------- DECLARE ALL GLOBAL VARIABLES HERE -------- */


int counter = 0; //Global counter variable used to keep track of number of contacts

char FileName[256]; //Array to hold the file name speficied by the user

FILE *pRead; //Global pointer to point to reading of the file

FILE *pWrite; //Global pointer to point to writing of the file using append to end of file.


//Begin main function

int main (void)

{   

phone *phonebook; //Phonebook entries pointer

phonebook = (phone*) malloc(sizeof(phone)*100); //Allocate memory for contacts

int iSelection = 0; //Variable to use to select menu choice


// Test if there is enough memory to allocate.

if (phonebook == NULL)

{

//Prompt the User that there is no more memory available for use.

printf("Out of Memory. The program will now exit");

return 1;

}

else {} //Do Nothing

do

{

print(" Sheree Rivers, CECS 121, Phone Book, July 8, 2013");

printf(" Phonebook Menu");

printf(" (1) Add Friend");

printf(" (2) Delete Friend");

printf(" (3) Display Phonebook Entries");

printf(" (4) Sort Entries by First Name");

printf(" (5) Sort Entries by Last Name");

printf(" (6) Search for Phone Number");

printf(" (7) Find a Random Friend");

printf(" (8) Delete All Entries");

printf(" (9) Exit Phonebook");

printf(" What would you like to do? ");

scanf("%d", &iSelection); //Stores menu choice into variable iSelection

// Add Friend

if (iSelection == 1)

{

AddEntry(phonebook); //Calls AddEntry Function

} //End if

  

//Delete Friend

if (iSelection == 2)

{

DeleteEntry(phonebook); //Calls DeleteEntry Function

} //End if

  

//Print Phonebook Entries

if (iSelection == 3)

{

PrintEntry(phonebook); //Calls PrintEntry Function

} //End if


//Sort Alphabetically by First Name

if (iSelection == 4)

{

SortByFirstName(phonebook); //Calls SortByFirstName Function

} //End if

//Sort Alphabetically by Last Name

if (iSelection == 5)

{

SortByLastName(phonebook); //Calls SortByLastName Function

} //End if

  

//Find a Phone Number by Searching by First and Last Name

if (iSelection == 6)

{

SearchForNumber(phonebook); //Calla SearchForNumber Function   

} //End if

  

//Find a Random Friend

if (iSelection == 7)

{

RandomName(phonebook); //Calls RandomName Function   

} //End if

//Delete All Phonebook Contacts

if (iSelection == 8)

{

DeleteAll(phonebook); //Calls DeleteAll Function

} //End if


//Exit Application

if (iSelection == 9)

{

printf(" You have chosen to exit the Phonebook. ");

system("pause");

FreeContacts(phonebook);

return 0;

} //End if

} while (iSelection <= 9); //End Do-While

} //End main function


/* -------- DECLARE ALL FUNCTION DEFINITIONS HERE -------- */


//Function Definition to Add Contacts to the Phonebook

void AddEntry (phone * phonebook)


/* ---!--- Note: Counter - 1 because arrays begin at 0 and increment by 1 ---!--- */

{

(" First Name: ");

("%s", phonebook[counter-1].FirstName);

("Last Name: ");

("%s", phonebook[counter-1].LastName);

("Phone Number (XXX-XXX-XXXX): "); //X's in Parenthesis show the format for input

("%s", phonebook[counter-1].PhoneNumber);

(" Friend successfully added to Phonebook "); //Tells user the friend has been added to the Phonebook


{

} //End Adding Entries

void DeleteEntry (phone * phonebook)

{

int x = 0;

int i = 0;

char deleteFirstName[20]; // Temporary string for deletion of an entry - first name

char deleteLastName[20]; // Temporary string for deletion of any array - last name

printf(" First name: ");

scanf("%s", deleteFirstName);

printf("Last name: ");

scanf("%s", deleteLastName);

//Compare strings, find entry or return entry not found

for (x = 0; x < counter; x++)

{

if (strcmp(deleteFirstName, phonebook[x].FirstName) == 0) //If deleteFirstName matches phonebook.FirstName

{

if (strcmp(deleteLastName, phonebook[x].LastName) == 0) //If deleteLastName matches phonebook.LastName

{

for ( i = x; i < counter - 1; i++ )

{

strcpy(phonebook[i].FirstName, phonebook[i+1].FirstName); //Delete first name

strcpy(phonebook[i].LastName, phonebook[i+1].LastName); //Delete last name

strcpy(phonebook[i].PhoneNumber, phonebook[i+1].PhoneNumber); //Delete the phone number

} //End inner For Loop

printf("Record deleted from the phonebook. ");

--counter; // Contact deleted, update the contact total counter

return;

} //End inner If

} //End outer If

} // End outer For loop

// Else Print that the Contact Was Not Found

printf("That contact was not found, please try again.");

} //End Deleteing Entries


// Function Definition to Print All Phonebook Contacts

void PrintEntry (phone * phonebook)

{

int x = 0;

printf(" Phonebook Entries: ");

pRead = fopen("phonebook_contacts.dat", "r");

if ( pRead == NULL)

{

perror("The following error occurred: ");

  

}

else

{

for( x = 0; x < counter; x++) //For loop to print entries

{

printf(" (%d) ", x+1); //Prints Contact Number in Phonebook

printf("Name: %s %s ", phonebook[x].FirstName, phonebook[x].LastName); //Contact's First and Last Name

printf("Number: %s ", phonebook[x].PhoneNumber); //Contact's Phone Number

} //End for loop

} //End else   

fclose(pRead);

} //End Printing Entries


//Function Definition to Sort Contacts By First Name and Display Them

void SortByFirstName (phone * phonebook)

{

int i = 0;

int x = 0;

int swap;

int TempCounter = counter;

phone Temp; //Temporary instance of phonebook struct to carry details

do

{

swap = 0;

for(i = 1; i < TempCounter; i++)

{

//If the comparison between the first string and the second string is greater than 0

//Then the first string is larger than the second.

//Switch the order of the two through a for loop using String Compare Function.

if(strcmp(phonebook[i-1].FirstName, phonebook[i].FirstName) > 0)

{

Temp = phonebook[i]; //Assign Temporary instance of phone struct to first entry

phonebook[i] = phonebook[i-1]; //Assign the first entry to the second entry

phonebook[i-1] = Temp; //Reassign the Temporary instance to the second entry

  

strcpy(Temp.FirstName, phonebook[i].FirstName);

strcpy(Temp.LastName, phonebook[i].LastName);

strcpy(Temp.PhoneNumber, phonebook[i].PhoneNumber);

  

swap = 1;

}// End if

} //End For Loop

TempCounter--;

} while (swap); //End Do-While Loop

printf(" Your friends in Alphabetical Order by First Name: ");

for( x = 0; x < counter; x++ )

{

printf(" (%d) ", x+1); //Prints Contact Number in Phonebook

printf("Name: %s %s ", phonebook[x].FirstName, phonebook[x].LastName); //Contact's First and Last Name

printf("Number: %s ", phonebook[x].PhoneNumber); //Contact's Phone Number

} //End For Loop

} //End SortByFirstName


//Function Definition to Sort Contacts By Last Name and Display Them

void SortByLastName (phone * phonebook)

{

int i = 0;

int x = 0;

int swap;

int TempCounter = counter;

phone Temp; //Temporary instance of phonebook struct to carry details

do

{

swap = 0;

for(i = 1; i < TempCounter; i++)

{

//If the comparison between the first string and the second string is greater than 0

//Then the first string is larger than the second.

//Switch the order of the two through a for loop using String Compare Function.

if(strcmp(phonebook[i-1].LastName, phonebook[i].LastName) > 0)

{

Temp = phonebook[i]; //Assign Temporary instance of phone struct to first entry

phonebook[i] = phonebook[i-1]; //Assign the first entry to the second entry

phonebook[i-1] = Temp; //Reassign the Temporary instance to the second entry

  

strcpy(Temp.FirstName, phonebook[i].FirstName);

strcpy(Temp.LastName, phonebook[i].LastName);

strcpy(Temp.PhoneNumber, phonebook[i].PhoneNumber);

  

swap = 1;

}// End if

} //End For Loop

TempCounter--;

} while (swap); //End Do-While Loop

printf(" Your friends in Alphabetical Order by First Name: ");

for( x = 0; x < counter; x++ )

{

printf(" (%d) ", x+1); //Prints Contact Number in Phonebook

printf("Name: %s %s ", phonebook[x].FirstName, phonebook[x].LastName); //Contact's First and Last Name

printf("Number: %s ", phonebook[x].PhoneNumber); //Contact's Phone Number

} //End For Loop

} //End SortByLastName


//Function Definition to Find a Specific Phone Number by Searching by First and Last Name

void SearchForNumber (phone * phonebook)

{

int x = 0;

char TempFirstName[20]; //Temporary Array to hold first name to find

char TempLastName[20]; //Temporary Array to hold last name to find

  

printf(" Please type the name of the friend you wish to find a number for.");

printf(" First Name: ");

scanf("%s", TempFirstName);

printf("Last Name: ");

scanf("%s", TempLastName);

for (x = 0; x < counter; x++)

{

if (strcmp(TempFirstName, phonebook[x].FirstName) == 0) //If TempFirstName matches phonebook.FirstName

{

if (strcmp(TempLastName, phonebook[x].LastName) == 0) //If TempLastName matches phonebook.LastName

{

//Print the Name and Number that matches the contact found

printf(" %s %s's phone number is %s ", phonebook[x].FirstName, phonebook[x].LastName, phonebook[x].PhoneNumber);

} //End inner if

} //End outer if

} //End for loop   

} //End SearchForNumber Function

//Function Definition to Generate a Random Friend to Display

void RandomName (phone * phonebook)

{

int iRandom = 0;

srand(time(NULL));

iRandom = rand() % counter; //Getting a random number from 0 to the number of contacts

int x = iRandom; //Assign x the value of the random number

printf(" Your random friend is: %s %s ", phonebook[x].FirstName, phonebook[x].LastName);

printf("Their phone number is: %s ", phonebook[x].PhoneNumber);

} //End Random Friend Generator   

//Function Definition to Delete All Phonebook Contacts

void DeleteAll (phone * phonebook)

{

int x = 0;

char nullStr[20] = {''}; //Create a NULL String to copy into the phonebook

for ( x = 0; x < counter; x++ )

{

strcpy(phonebook[x].FirstName, nullStr); //Copy a Null String into the phonebook

strcpy(phonebook[x].LastName, nullStr); //Copy a Null String into the phonebook

strcpy(phonebook[x].PhoneNumber, nullStr); //Copy a Null String into the phonebook

--counter; //Decrement counter to account for deleted contacts

} //End For loop   

//Tell user that the contacts have been deleted

printf("All Contacts have been deleted. ");

} //End Deleteing All Contacts

{

  

}

getch();

return;

Explanation / Answer

Because you did'nt close the bracket properly before so you got the error I have posted your code here http://web.iiit.ac.in/~kondetimanikanta.purushotham/x.cpp