im new with c++ and my lecturer given this question and ask me to solve it. it is difficult to understand it. anyone can help me,pls?
Given the structure

typedef struct {
char Firstname[20];
char Lastname [20];
char add[20];
char city[20];
char state[20];
char zip[6];
char phone[15];
}student;

Student stu[100];

Write a program, which will ask the user to enter the number of students’ record they want to store. The program should accept student’s first name, last name, address, city, state, zip code and phone number. The user must be able to store at least (minimum) 5 students’ records. Then prompt a menu to give the user choice, either to display the particulars entered or to exit from the program. Before display the particulars, the program should print the student a number, followed by his/her particulars (first name, last name, address, city, state, zip code and phone number). Example, for the first student record, display student number: 1, for the second student record, print student number…. Before exit from the program write all the students’ record into a text file called as student.txt.

i already wrote it.. can you guyz help me check where is the mistake?

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
void menu(void);
void NEW(void);
void EDIT(void);
void qtype(void);
void category(void);
void main()
{
 menu();
}
void menu(void){
int x;

do {
 // system("CLS")
printf("****************************\n");
printf("**** Main Menu ****\n");
printf("**** [1] NEW  ****\n");
printf("**** [2] EDIT ****\n");
printf("**** [3] EXIT ****\n");
printf("****************************\n");
printf("Please press a number to make your selection");
scanf("%d",&x);
if(x==1)
 NEW();
else
if(x==2)
 EDIT();
else
if(x==3)
printf("You must enter only 1, 2 or 3\n");
}while(x != 3);
}
void NEW(void){
 category();
}
void EDIT(void){
 printf("this is stub: it means you have not coded the function yet\n");
}
void category(void){
 int y;
 typedef struct {
 char FirstName[20];
 char LastName[20];
 char add[20];
 char city[20];
 char state[20];
 char zip[6];
 char phone[15];
}student;
student stu[100];
system("CLS");
printf("[1] NEW\n");
printf("[2] EDIT\n");
printf("[3] EXIT\n");
printf("Enter a selection >> \n");
scanf("%d",&y);
system("CLS");
if(y==1)
printf("FirstName LastName Address  City State ZipCode  PhoneNumber\n");
qtype();
if(y==2)
printf("FirstName LastName Address  City State ZipCode  PhoneNumber\n");
qtype;
if(y==3)
return;
category();
}

Not without code tags and an explanation of what is wrong. We aren't psychic...

When you typed in your posts, did you notice the background was not pure white? They are actually words. They can help.

i already wrote it.. can you guyz help me check where is the mistake?

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
void menu(void);
void NEW(void);
void EDIT(void);
void qtype(void);
void category(void);
void main()
{
menu();
}
void menu(void){
int x;

do {
// system("CLS")
printf("****************************\n");
printf("**** Main Menu ****\n");
printf("**** [1] NEW ****\n");
printf("**** [2] EDIT ****\n");
printf("**** [3] EXIT ****\n");
printf("****************************\n");
printf("Please press a number to make your selection");
scanf("%d",&x);
if(x==1)
NEW();
else
if(x==2)
EDIT();
else
if(x==3)
printf("You must enter only 1, 2 or 3\n");
}while(x != 3);
}
void NEW(void){
category();
}
void EDIT(void){
printf("this is stub: it means you have not coded the function yet\n");
}
void category(void){
int y;
typedef struct {
char FirstName[20];
char LastName[20];
char add[20];
char city[20];
char state[20];
char zip[6];
char phone[15];
}student;
student stu[100];
system("CLS");
printf("[1] NEW\n");
printf("[2] EDIT\n");
printf("[3] EXIT\n");
printf("Enter a selection >> \n");
scanf("%d",&y);
system("CLS");
if(y==1)
printf("FirstName LastName Address City State ZipCode PhoneNumber\n");
qtype();
if(y==2)
printf("FirstName LastName Address City State ZipCode PhoneNumber\n");
qtype;
if(y==3)
return;
category();
}

1. main returns int not void
2. Did you check my previous link?
3. Use code tags if you need further help like said by Waltp

1) This code is in C, not C++.

2) As sunny pointed out, main() should return an int. If your professor wrote that part, well, don't copy them in the future ;)

3) For this code segment:

void EDIT(void)
{
  printf("this is stub: it means you have not coded the function yet\n");
}

You obviously haven't finished. I'm guessing it's because you've not done the input either.

4) The work for catalog() is, well, missing. Let's walk through it:

void category(void){
  int y;
  typedef struct {
    char FirstName[20];
    char LastName[20];
    char add[20];
    char city[20];
    char state[20];
    char zip[6];
    char phone[15];
  }student;
  student stu[100];
  system("CLS");
  printf("[1] NEW\n");
  printf("[2] EDIT\n");
  printf("[3] EXIT\n");
  printf("Enter a selection >> \n");
  scanf("%d",&y);
  system("CLS");

This part is mostly fine, 'cept for the system("CLS"), which is system specific. You probably don't need to worry about that for this assignment, but keep it in mind.

if(y==1)
    printf("FirstName LastName Address  City State ZipCode  PhoneNumber\n");
  qtype();
  if(y==2)
    printf("FirstName LastName Address  City State ZipCode  PhoneNumber\n");
  qtype;
  if(y==3)
    return;
  category();
}

This bit is messed up. If the user hits 1, e.g. to enter new information, you print out some text and move on. If the user hits 2, same thing happens. If the user hits 3, you return from the function. And instead of having the function call itself, it's probably better to handle the menu with a loop, like you did earlier (in menu()).

Overall, you don't even input data from the user and never let them edit data (which they can't put in anyways). You need to add those functionalities to the program.

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.