Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7934049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:31:22+00:00 2026-06-03T21:31:22+00:00

So what I am trying to do is write a simple program with a

  • 0

So what I am trying to do is write a simple program with a main menu where the user will be able to fill in the details of a project,list all projects, delete a chosen project or exit the program. Projects will be saved in an array. The functions will use structures.

I have written a functional code which compiles fine(big deal lol i know) but thus far only the 4th option “exit” works. The other 3 choices seem to not be working.

Here’s my code:

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

struct fullname
{
        char name[10];
        char surname[10];
};
struct meletes
{
        int identifier;
        struct fullname customer;
        char date[10];
        float price;
};
void initialize(struct meletes projects[10]);
struct meletes newp(struct meletes projects[10]);
struct meletes list(struct meletes projects[10]);
struct meletes deletep(struct meletes projects[10]);

int main(void)
{
int choice,k;
struct meletes projects[10];

void initialize(struct meletes projects[10]);

printf("Main Menu\n ========\n");
printf("Please choose a function from below:\n");
printf("1.New Project\n2.Delete\n3.List\n4.Exit\n");
scanf("%d", &choice);

    while ((choice != 1) && (choice != 2) && (choice != 3) && (choice != 4))
          {

           printf("You have chosen a wrong function, please use numbers 1-4:\n\n");
           printf("Main Menu\n ========\n");
           printf("Please choose a function from below:\n");
           printf("1.New Project\n2.Delete\n3.List\n4.Exit\n");
           scanf("%d", &choice);
           }

          while (choice != 4)
          {
          switch (choice) {

                 case 1:
                 {
                  struct meletes newp(struct meletes projects[10]);

                  }

                 case 2:
                 {
                  struct meletes deletep(struct meletes projects[10]);

                  }

                 case 3:
                 {
                  struct meletes list(struct meletes projects[10]);

                  }
                         }


            printf("Main Menu\n ========\n");
            printf("Please choose a function from below:\n");
            printf("1.New Project\n2.Delete\n3.List\n4.Exit\n");
            scanf("%d", &choice);             

          }        

          printf("Thank u.\n");

system("pause");
return 0;
}

 void initialize(struct meletes projects[10])
 {
int l;
 for(l=0; l<10; l++)
  {
          projects[l].identifier = 00000;
          projects[l].price = 0.00;
          strcpy(projects[l].customer.name,"----------");
          strcpy(projects[l].customer.surname,"----------");
          strcpy(projects[l].date, "0/0/0");
  }          
}          

struct meletes newp(struct meletes projects[10])
{
        int i;
        for(i=0; i<10; i++)
        {
                  if (projects[i].identifier == 00000)
                 {
                    scanf("Please enter the project's identifier %d\n",        &projects[i].identifier);
                    scanf("Name:%s\n", &projects[i].customer.name);
                    scanf("Surname:%s\n", &projects[i].customer.surname);
                    scanf("Give the date in dd/mm/yyyy! format :%c\n", &projects[i].date);
                    scanf("Price:&f\n", &projects[i].price);
                 }
             break;
        }                

}

struct meletes deletep(struct meletes projects[10])
{
       int j,id;
        for (j=0; j<10; j++)
        {
            if (projects[j].identifier != 00000)     //Emfanizei oles tis meletes pou den ine diegrammenes
               {
               printf("%d\n", projects[j].identifier);
               }
        }

        scanf("\nPlease insert the identifier of the project u want to delete:%d", &id);

        for(j=0; j<10; j++)
        {                       
          projects[j].identifier = 00000;
          projects[j].price = 0.00;
          strcpy(projects[j].customer.name,"----------");
          strcpy(projects[j].customer.surname,"----------");
          strcpy(projects[j].date, "0/0/0");
        }

}

struct meletes list(struct meletes projects[10])
{
       int k;
        for(k=0; k<10; k++)
        {
                 if (projects[k].identifier != 00000); 
                    {
                    printf("         Project %d:", k);
                    printf("\nIdentifier:%d\n", projects[k].identifier);
                    printf("Name:%s\n", projects[k].customer.name);
                    printf("Surname:%s\n",projects[k].customer.surname);
                    printf("Date:%s\n", projects[k].date);
                    printf("Price:%d\n", projects[k].price);
                    }
        }

 }        `

Any ideas will be really appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:31:24+00:00Added an answer on June 3, 2026 at 9:31 pm

    Here is a working example. Please look this over and let us know what you learned.

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    typedef struct 
    {
            char name[10];
            char surname[10];
    }fullname;
    
    typedef struct 
    {
            int identifier;
            fullname customer;
            char date[10+1]; /* need a NULL */
            float price;
    }meletes;
    
    void initialize(meletes *projects);
    meletes *newp(meletes *projects);
    void list(meletes *projects);
    void deletep(meletes *projects);
    
    int main(int argc, char *argv[])
    {
    
        int choice,k;
        meletes projects[10];
        meletes *retMeletes;
    
        initialize(projects);
    
        printf("Main Menu\n ========\n");
        printf("Please choose a function from below:\n");
        printf("1.New Project\n2.Delete\n3.List\n4.Exit\n");
        scanf("%d", &choice);
    
        while ((choice != 1) && (choice != 2) && (choice != 3) && (choice != 4))
        {
    
               printf("You have chosen a wrong function, please use numbers 1-4:\n\n");
               printf("Main Menu\n ========\n");
               printf("Please choose a function from below:\n");
               printf("1.New Project\n2.Delete\n3.List\n4.Exit\n");
               scanf("%d", &choice);
        }
    
        while (choice != 4)
        {
            switch (choice)
            {
                case 1:
                    retMeletes = newp( projects);
                break;
    
                case 2:
                    deletep(projects);
                break;
    
                case 3:
                    list(projects);
                break;
            }
    
            printf("Main Menu\n ========\n");
            printf("Please choose a function from below:\n");
            printf("1.New Project\n2.Delete\n3.List\n4.Exit\n");
            scanf("%d", &choice);             
        }
    
        printf("Thank u.\n");
    
        system("pause");
        return 0;
    }
    
    void initialize(meletes *projects)
    {
        int l;
        for(l=0; l<10; l++)
        {
            projects[l].identifier = 00000;
            projects[l].price = 0.00;
            strcpy(projects[l].customer.name,"----------");
            strcpy(projects[l].customer.surname,"----------");
            strcpy(projects[l].date, "00/00/0000");
        }          
    }          
    
    meletes *newp(meletes *projects)
    {
        int i;
    
        for(i=0; i<10; i++)
        {
            if (projects[i].identifier == 0)
            {
                printf("Please enter the project's identifier: ");
                scanf("%d", &projects[i].identifier);
                printf("Name: ");
                scanf("%s", &projects[i].customer.name);
                printf("Surname: ");
                scanf("%s", &projects[i].customer.surname);
                printf("Give the date in dd/mm/yyyy! format: ");
                memset( &projects[i].date, 0x00, sizeof( projects[i].date ));
                scanf("%s", &projects[i].date );
                printf("Price: ");
                scanf("%f", &projects[i].price);
                break;
            }
        }                
        return( &projects[i] );
    }
    
    void deletep(meletes *projects)
    {
        int j,id;
    
        for (j=0; j<10; j++)
        {
            if (projects[j].identifier != 0)     //Emfanizei oles tis meletes pou den ine diegrammenes
            {
                printf("%d\n", projects[j].identifier);
            }
        }
    
        printf("\nPlease insert the identifier of the project u want to delete: ");
        scanf("%d", &id);
    
        projects[id-1].identifier = 0;
        projects[id-1].price = 0.00;
        strcpy(projects[id-1].customer.name,"----------");
        strcpy(projects[id-1].customer.surname,"----------");
        strcpy(projects[id-1].date, "0/0/0");
    
        return;
    }
    
    void list(meletes *projects)
    {
        int k;
    
        for(k=0; k<10; k++)
        {
            if (projects[k].identifier != 00000); 
            {
                printf("         Project %d:", k);
                printf("\nIdentifier:%d\n", projects[k].identifier);
                printf("Name:%s\n", projects[k].customer.name);
                printf("Surname:%s\n",projects[k].customer.surname);
                printf("Date:%s\n", projects[k].date);
                printf("Price:%f\n", projects[k].price);
            }
        }
        return;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a simple program that will receive a string of max
I'm trying to write a simple program that will compare the files in separate
I'm trying to write a simple program where it ask user to enter a
I'm trying to write very simple program which will imitate simple DeadLock, where Thread
I am trying to write a simple program to open a socket channel to
I'm new to Pascal and I am trying to write a simple program, but
I'm trying to write a simple curl program to retrieve the web page in
I'm trying to write a very simple program, I want to print out the
I'm trying to write a simple stock check program, and I have a Table
I'm trying to write a simple spell checking program for homework, basically by putting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.