图书管理系统——C++实现


纯C++程序,不含数据库,简单易读。。。。。。。。。。
资源截图
代码片段和文件信息
#include “Book.h“
#include
#include
#include
#include
#include
#include
using namespace std;

Book::Book(char* booknochar* Name char* lsbn char* Price char* Author char* time char* banci) {
strncpy(m_bookno bookno NUM2);
strncpy(m_Name Name NUM1);
strncpy(m_lsbn lsbn NUM1);
strncpy(m_Price Price NUM2);
strncpy(m_Author Author NUM2);
strncpy(m_time time NUM1);
strncpy(m_banci banci NUM1);
}

char* Book::Getbookno() {
return m_bookno;
}
void Book::Setbookno(char* bookno) {
strncpy(m_bookno bookno NUM2);
}

char* Book::GetName() {
return m_Name;
}
void Book::SetName(char* Name) {
strncpy(m_Name Name NUM1);
}

char* Book::Getlsbn() {
return m_lsbn;
}
void Book::Setlsbn(char* lsbn) {
strncpy(m_lsbn lsbn NUM1);
}

char* Book::GetPrice() {
return m_Price;
}
void Book::SetPrice(char* Price) {
strncpy(m_Price Price NUM2);
}

char* Book::GetAuthor() {
return m_Author;
}
void  Book::SetAuthor(char* Author) {
strncpy(m_Author Author NUM2);
}

char* Book::Gettime() {
return m_time;
}
void Book::Settime(char* time) {
strncpy(m_time time NUM1);
}

char* Book::Getbanci() {
return m_banci;
}
void Book::Setbanci(char* banci) {
strncpy(m_banci banci NUM1);
}

void Book::WriteData() {
ofstream file;
file.open(“F://book.dat“ ios::binary | ios::app);
try {
file.write(m_bookno NUM2);
file.write(m_Name NUM1);
file.write(m_lsbn NUM1);
file.write(m_Price NUM2);
file.write(m_Author NUM2);
file.write(m_time NUM1);
file.write(m_banci NUM1);
}
catch (...) {
throw “file error occurred“;
file.close();
}
file.close();
}

void Book::GetBookFromFile(int count) {
char bookno[NUM2];
char Name[NUM1];
char lsbn[NUM1];
char Price[NUM2];
char Author[NUM2];
char time[NUM1];
char banci[NUM1];
ifstream file;
file.open(“F://book.dat“ ios::binary);
try {
file.seekg(count*(NUM1 + NUM1 + NUM2 + NUM2+NUM1+NUM1+NUM2) ios::beg);
file.read(bookno NUM2);
if (file.tellg() > 0) {
strncpy(m_bookno bookno NUM2);
}
file.read(Name NUM1);
if (file.tellg() > 0) {
strncpy(m_Name Name NUM1);
}
file.read(lsbn NUM1);
if (file.tellg() > 0) {
strncpy(m_lsbn lsbn NUM1);
}
file.read(Price NUM2);
if (file.tellg() > 0) {
strncpy(m_Price Price NUM2);
}
file.read(Author NUM2);
if (file.tellg() > 0) {
strncpy(m_Author Author NUM2);
}
file.read(time NUM1);
if (file.tellg() > 0) {
strncpy(m_time time NUM1);
}
file.read(banci NUM1);
if (file.tellg() > 0) {
strncpy(m_banci banci NUM1);
}
}
catch (...) {
throw“file error occurred“;
file.close();
}
file.close();
}

void Book::DeleteData(int count) {
long respos;
int DataCount = 0;
fstream file;
fstream tmpfile;
ofstream ofile;
char TempBuf[NUM1 + NUM1 + NUM2 + NUM2+NUM1+NUM1+NUM2];
file

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-07-03 10:27  图书管理系统
     目录           0  2017-07-12 20:02  图书管理系统.vs
     目录           0  2018-07-10 17:15  图书管理系统.vs图书管理系统
     目录           0  2017-07-12 20:02  图书管理系统.vs图书管理系统v14
     文件       28672  2018-07-03 10:27  图书管理系统.vs图书管理系统v14.suo
     目录           0  2018-07-10 21:44  图书管理系统.vs图书管理系统v15
     文件       31232  2018-07-10 21:51  图书管理系统.vs图书管理系统v15.suo
     文件     5586944  2018-07-10 21:51  图书管理系统.vs图书管理系统v15Browse.VC.db
     目录           0  2018-07-10 17:16  图书管理系统.vs图书管理系统v15ipch
     目录           0  2018-07-10 17:16  图书管理系统.vs图书管理系统v15ipchAutoPCH
     目录           0  2018-07-10 17:16  图书管理系统.vs图书管理系统v15ipchAutoPCHa6f25914ce4f78dd
     文件    34471936  2018-07-10 21:44  图书管理系统.vs图书管理系统v15ipchAutoPCHa6f25914ce4f78ddBOOK.ipch
     目录           0  2018-07-10 17:16  图书管理系统Debug
     文件      156672  2018-07-10 17:16  图书管理系统Debug图书管理系统.exe
     文件      749436  2018-07-10 17:16  图书管理系统Debug图书管理系统.ilk
     文件      700416  2018-07-10 17:16  图书管理系统Debug图书管理系统.pdb
     目录           0  2018-07-10 17:16  图书管理系统图书管理系统
     文件    10747904  2018-07-03 10:27  图书管理系统图书管理系统.sdf
     文件        1336  2017-07-12 20:02  图书管理系统图书管理系统.sln
     文件     8638464  2017-07-28 17:31  图书管理系统图书管理系统.VC.db
     文件       22374  2018-06-20 20:30  图书管理系统图书管理系统Book.cpp
     文件        3673  2017-07-14 02:19  图书管理系统图书管理系统Book.h
     目录           0  2018-07-10 17:16  图书管理系统图书管理系统Debug
     文件      440870  2018-07-10 17:16  图书管理系统图书管理系统DebugBook.obj
     文件      781312  2018-07-03 10:27  图书管理系统图书管理系统Debugvc140.idb
     文件      544768  2018-07-03 10:27  图书管理系统图书管理系统Debugvc140.pdb
     文件      150528  2018-07-10 17:16  图书管理系统图书管理系统Debugvc141.idb
     文件      487424  2018-07-10 17:16  图书管理系统图书管理系统Debugvc141.pdb
     文件       19442  2018-07-10 17:16  图书管理系统图书管理系统Debug图书管理系统.log
     目录           0  2018-07-10 17:16  图书管理系统图书管理系统Debug图书管理系统.tlog
     文件        1206  2018-07-10 17:16  图书管理系统图书管理系统Debug图书管理系统.tlogCL.command.1.tlog
............此处省略10个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)