从文件系统读取
Reading from File system
这是我的程序的摘录-我想显示存储在输出窗口中的文本。文本根据需要存储在文件中。但是,在阅读时,内容不显示在屏幕上。应该做出哪些改变?
ofstream out("Welcome");
out<<" WELCOME TO MAIN BANK ATM SIMULATOR "<<endl;
out<<"Select operation mode:n1. Administrator Moden2. User Moden3. Exit"<<endl;
out.close();
ifstream in("Welcome");
char asd[100];
in>>asd;
cout<<asd<<endl;
in.close();
getch();
return 0;
在"Welcome"后面有一个空格。由于空格,它结束了读取。所以它只会显示"Welcome",如果没有空格,那么它会显示整个字符串
使用in.get(asd, 100)
(见这里)
我通常发现将流转换成字符串比转换成字符数组更容易。std:: string s;In>> s;cout<<p>请参阅本主题,以将整个文件读取为字符串https://stackoverflow.com/a/4457291/2212458
相关文章:
- 使用新行和不使用新行读取文件
- 读取文件并输入到矢量中
- 读取文件的最后一行并输入到链接列表时出错
- 为什么在读取文件大小时文件IO速度会发生变化
- 文件系统:复制功能的速度秘诀是什么
- c++17文件系统::recursive_directory迭代器()在mac上没有给出这样的目录,但在windows上
- 读取文件时运行时的未知行为
- 如何传递多个 std::文件系统选项?
- 遍历顺序由 std::文件系统directory_iterator给出
- 如何逐行读取文件,每行中的内容都用空格分隔并将其写入新文件中
- 在嵌入式系统中读取文件的内存碎片
- 如何读取/查询文件系统和文件结构
- 在C++中读取文件系统时出现问题(Boost 未编译)
- Qt5:如何在本地文件系统中读取/写入文件
- 从 boost 1.48 升级到 1.49 具有文件系统路径访问冲突读取位置0x0000000
- 如何使用C读取NTFS文件系统的元文件
- 不使用Inotify从Linux内核读取文件系统事件
- 从文件系统读取
- 缓存对象应该直接从文件系统中读取吗?
- 在系统启动时从注册表读取文件[c++]