在 C++ 中包含库数据库.txt文件时出错
error in including library database.txt file in c++
我正在制作一个图书馆管理系统,包括包含书籍信息和书籍分配信息的文本文件。但它显示错误。我有一个数据库.txt文件,其中给出了书籍的名称和书籍的分配。请帮忙...
我的代码是
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include "C:UsersRitesh Singh ChauhanDesktoplibrarydatabase.txt"
char name[20];
char book[20];
char person[20];
void searchBook()
{
ifstream infile;
infile.open("librarydatabase.txt");
cout<<"enter name of book";
cin>>name;
infile>>name;
cout<<name<<endl;
infile.close();
}
void addNewBook()
{
ofstream outfile;
outfile.open("librarydatabase.txt");
cout<<"enter name of book";
cin>>book;
outfile<<book<<endl;
cout<<"successfully added";
outfile.close();
}
void allotmentList()
{
cout<<"enter name of person";
cin>>person;
}
void exitLib()
{
//exit();
}
void main()
{
clrscr();
int number;
cout<<"press 1 to search book"<<" "<<"press 2 to add a new book"<<" "
<<"press 3 to allotment list by person"<<" "<<"press 4 to exit";
cin>>number;
switch(number)
{
case 1: searchBook();
break;
case 2: addNewBook();
break;
case 3: allotmentList();
break;
case 4: exitLib();
break;
default: cout<<"press number between 1 to 4";
}
[code is showing error and an error message is given in image][1]}
从代码中删除以下行
#include "C:UsersRitesh Singh ChauhanDesktoplibrarydatabase.txt"
和 更改行
infile.open("librarydatabase.txt");
自
infile.open("C:\Users\Ritesh Singh Chauhan\Desktop\librarydatabase.txt");
相关文章:
- 读取文件的最后一行并输入到链接列表时出错
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- .h 和.cpp文件分离时出错,但仅使用 .h 文件时没有错误.我做错了什么?
- 在 C/C++ 中打开驻留在 "/sys/" 下的文件时出错
- 在头文件中定义变量不会出错
- 如何在多写入器情况下对文件支持的共享内存中的大页面出错
- JNI,使用两个 .so 文件时出错,其中一个文件需要另一个文件
- 生成文件中隐式规则中的 -c 标志出错
- 编译时出错 - 链接.cpp和头文件
- 从人员矢量插入和读取文件时出错
- LNK2019 在文件中调用静态成员的方法时出错.cpp
- ./main:加载共享库时出错:libopencv_highgui.so.4.0:无法打开共享对象文件:没有这样的文件或
- 猫鼬 - 包含标准C++库文件时出错
- 在f2c.h文件中定义min()max()宏时出错
- ASIOSDK;从hostsample.cpp生成mex文件时出错
- 使用emscripten将c++文件转换为wasm时出错
- 编译后可执行文件出错
- 头文件C++出错
- ftell 非常大的文件出错
- 从磁盘读取映像文件出错