C++ implements a simple information management system

  • 2020-05-10 18:31:15
  • OfStack

This paper for you to share C++ to achieve a simple information management system, this site before learning to do some management system, on the Internet to check a lot of information, now I share the information to you, hope to help you.


#include <stdio.h>
#include <stdlib.h>
#include "file.h"
 
 
 
void savaList(Node *head)/** Store the data entered by the user in a file for easy reading next time */
{
 FILE *fp=fopen("data\\data.txt" ,"w") ;
 Node *p ;
 for(p=head->next;p;p=p->next)
 {
   fwrite(&(p->data),sizeof(students),1,fp) ;
 }
 fclose(fp) ;
 
}
 
 
 
void duquLisr(Node *head)/** Read the data previously entered by the user  */
{
 FILE *fp=fopen("data\\data.txt" ,"r") ;
 students e ;
  while( fread(&e,sizeof(students) ,1,fp ) )
  {
   insertList(head,e) ;
  }
  fclose(fp) ;
 
}
 
 
 
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "goods.h"
 
/** Input data, function purpose return 1 a goods The value of the type */  /**      char name[M] ;
                   char phone[M] ;
                   char street[M] ;
                   char city[M] ;
                   char youb[M] ; */
students lurushuju()
{
 students e ;
 
 
 printf(" Please enter the student's name  ") ;
 scanf("%s",e.name);
 
 printf(" Please enter the student's phone number  ") ;
 scanf("%s",e.phone) ;
 
 printf(" Please enter the student's street  ") ;
 scanf("%s",e.street) ;
 
 printf(" Please enter the student's city information  ") ;
 scanf("%s",e.city) ;
 
 printf(" Please enter the student's zip code  ") ;
 scanf("%s",e.youb) ;
 
 
 return e ;
 
}
void shuchushuju(students e)/** Output data in sequence e*/
{
 printf("%15s%15s%15s%15s%15s\n" , e.name ,e.phone,e.street,e.city,e.youb) ;
 
}
void xiugaishuju(students *e)/** Modify the data according to the address e Individual data inside */ /** Select the data you want to modify by selecting the sequence number */
{
 int score ;
 int count=1 ;
 printf(" Please enter the data type you want to modify \n") ;
 do
 {
 printf("1. The name; 2. The phone; 3. Street information; 4. City information; 5. Zip code; 6. exit \n");
 scanf("%d",&score) ;
 switch(score)
 {
 case 1:
  scanf("%s",e->name);
  break ;
 case 2:
  scanf("%s",e->phone) ;
  break;
 case 3:
  scanf("%s",e->street) ;
  break ;
 case 4:
  scanf("%s",e->city) ;
  break ;
 case 5:
  scanf("%s",e->youb) ;
  break ;
 default:
  count=0;
 }
 }while(count);
 
}
 
 
 
 
#include <stdio.h>
#include <string.h>
#include "list.h"
#include "goods.h"
 
void creatList(Node *head,int n)/** create 1 A length of n The list of */
{
 int i ;
 students p ;
 for(i=1; i<=n ; i++)
 {
  p=lurushuju() ;
  insertList(head,p) ;
 }
 
}
void insertList(Node *head,students e) /** the e In a 1 A value to 1 Insert in the specified order head The linked list for the header node goes above */
{
 Node *p;
 Node *q;
 q=(Node*)malloc(sizeof(Node));
 q->data=e;
 for(p=head; p->next && strcmp( (p->next)->data.name,e.name)<0 ;p=p->next ) ;
 q->next=p->next;
 p->next=q;
}
 
int delList(Node *head,char e[])/** Name the list as e the 1 Delete the item, find it and return it 1 , or return 0*/
{
 Node *p;
 for(p=head; p->next && strcmp(e,p->next->data.name) ;p=p->next) ;
 if(p->next ==0)
 {
  return 0 ;
 }
 else
 {
  Node *t;
  t=p->next;
  p->next=t->next;
  free(t);
  return 1 ;
 }
 
}
 
 
Node *searchList(Node *head,char e[])/** Look up the name in the linked list 1 The item finds the address that returns this node   No return null*/
{
 Node *p;
 for(p=head; p && strcmp(e,p->data.name) ; p=p->next ) ;
 return p ;
}
 
 
void disputList(Node *head)/** Sequential output head The list */
{
 Node *p;
 for(p=head->next;p;p=p->next)
 shuchushuju(p->data);
 
 
}
 
void changeList(Node *head ,char e[]) /** Modify something in a linked list 1 A node data value */ /** The system can only be found by name   The follow-up is improving. */
{
 Node *p ;
 p=searchList(head,e) ;
 if(!p)
 {
  printf("error\n");
 }
 else
 {
  xiugaishuju(&(p->data)) ;
 
 }
 
}
void destroy(Node *head)
{
 Node *p;
 for(p=head;p;p=p->next)
  free(p);
}
 
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "list.h"
#include "goods.h"
 
void mainmenu(Node *head)
{
 int scored ;
 int count=1 ;
 char e[100] ;
 int n;
 students p;
 do
 {
 printf("================**** Student information management system ( beta by Lee voyage )****=====\n") ;
 printf("========================== start ===============================\n");
 printf("==1. Input data  2. Modify the data  3. Display the data  4. Delete the data  5. Insert data =\n") ;
 printf("=======7. Read the data ========6. Save out =======8. exit =============\n") ;
 printf("=======================**********============================\n") ;
  printf(" Please enter what you want to do \n") ;
  scanf("%d",&scored);
 switch(scored)
 {
 case 1:
  printf(" Please enter about the student you want to save \n");
  scanf("%d",&n);
  creatList(head,n);
  break ;
 case 2:
  printf(" Please enter the name of the student to be changed \n") ;
  scanf("%s",e);
  changeList(head , e) ;
  break ;
 case 3:
  printf("    The name     The phone    The street information     City information    Email messages  \n") ;
  disputList(head) ;
  break ;
 case 4:
  printf(" Please enter the name of the student to be deleted \n");
  scanf("%s",e);
  n=delList(head, e) ;
  if(n)
  {
   printf(" Delete the success \n");
  }
  else
  {
   printf("error\n") ;
  }
  break ;
 case 5:
  printf(" Please enter the information you want to insert \n");
  p=lurushuju();
  insertList(head, p);
  break ;
 case 6:
  savaList(head);
  count=0;
  break ;
 case 7:
  duquLisr(head);
  break ;
 default :
  count=0;
 }
 system("pause") ;
 system("cls") ;
 
 }while(count);
 printf("\n\n\n\n Thank you for your support of this system, if you encounter it during use bug , please send email to 1277171561@qq.com\n\n\n\n\n\n\n") ;
 
 
}
 
 
 
int main()
{
 Node *head=(Node*)malloc(sizeof(Node));
 head->next=NULL ;
 mainmenu(head) ;
 destroy(head) ;
 return 0;
}
 
 
#ifndef FILE_H_INCLUDED
#define FILE_H_INCLUDED
#include "list.h"
 
void savaList(Node *head);/** Store the data entered by the user in a file for easy reading next time */
void duquLisr(Node *head);/** Read the data previously entered by the user  */
 
 
 
#endif // FILE_H_INCLUDED
 
 
 
#ifndef GOODS_H_INCLUDED
#define GOODS_H_INCLUDED
 
typedef struct students /* Define student information */
{
 char name[100] ;
 char phone[100] ;
 char street[100] ;
 char city[100] ;
 char youb[100] ;
 
}students;
 
students lurushuju();/** Input data, function purpose return 1 a goods The value of the type */
void shuchushuju(students e);/** Output data in sequence e*/
void xiugaishuju(students *e);/** Modify the data according to the address e Individual data inside */
 
 
 
 
 
#endif // GOODS_H_INCLUDED
 
 
 
 
#ifndef LIST_H_INCLUDED
#define LIST_H_INCLUDED
#include "goods.h"
 
typedef struct Node /** List structure */
{
 students data ;
 struct Node *next ;
}Node ;
 
void creatList(Node *head,int n);/** create 1 A length of n The list of */
void insertList(Node *head,students e) ;/** the e In a 1 A value to 1 Insert in the specified order head The linked list for the header node goes above */
int delList(Node *head,char e[]) ;/** Name the list as e the 1 Delete the item, find it and return it 1 , or return 0*/
Node *searchList(Node *head,char e[]) ; /** Look up the name in the linked list 1 item */
void disputList(Node *head);/** Sequential output head The list */
void changeList(Node *head ,char e[]) ;/** Modify something in a linked list 1 A node data value  */
void destroy(Node *head) ;/** destroy 1 Linked list data */
 
 
 
 
 
#endif // LIST_H_INCLUDED

The above is the C++ information management system key code, for your reference, below to share some other management system for you:

C++ to achieve a simple library management system

C++ to achieve a simple staff information management system

C++ basic student management system

For more information, please refer to the topic "management system development".

The above is the entire content of this article, I hope to help you with your study.


Related articles: