Question: At the top is the instructions, followed by my code. Please look over my code and make any edits neccessary and fix the following error

At the top is the instructions, followed by my code. Please look over my code and make any edits neccessary and fix the following error that I am getting whenever I try to run the program.

ERROR: When I run this I get the following error: exit status 1 main.c: In function 'main': main.c:96:1:error: expected declaration or statement at end of input } ^

Please make sure that all code is written in C ONLY.

Try to use the most elementary manner of doing this. Include output.

Create a Code Blocks project named LinkedLists.

This program will use a set of data structures into which the user will enter contact information. Globally declare a ContactInfo struct. Create a function that asks for contact information and places the information into a struct. ContactInfo *getContactInfo( void ); Call getContactInfo ten times from a for loop, and each time add the new data structure to the end of the list (use a function named addContactInfoToList( ContactInfo *info ) to add the new data structure to the list).. Write a function that displays all of the data in the list.

#include

#include

struct ContactInfo {

char name[20];

int mobile_no;

struct ContactInfo *next;

};

struct ContactInfo* getContactInfo (void)

{

struct ContactInfo *new;

new= (struct ContactInfo *) malloc (sizeof(struct ContactInfo));

printf("Enter the name:");

scanf("%s",new->name);

printf(" Enter the mobile number:");

scanf("%d",&new->mobile_no);

new->next=NULL; r

eturn new;

}

void display(struct ContactInfo* first)

{

int i;

for(i=0;i<10;i++)

{

printf("%s\t%d",first->name,first->mobile_no);

first=first->next;

}

}

void main()

{

struct ContactInfo *current=NULL;

struct ContactInfo *first=NULL;

int i;

for (i=0;i<10;i++)

{

current=getContactInfo();

if(i==0)

first=current;

current=current->next;

}

display(first);

}

ERROR: When I run this I get the following error: exit status 1 main.c: In function 'main': main.c:96:1:error: expected declaration or statement at end of input } ^

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!