如何使用 C++ 将测验分数存储在 TXT 文件中
how to store a quiz score in a txt file using c++
我是编程新手,我想解决的项目之一是测验,问题是我不知道如何将我的测验分数存储在文本文件中,有人可以帮忙吗?一个给定的例子会很好
这是 cplusplus 中给出的示例的略微修改的示例
// basic file operations
#include <iostream>
#include <fstream>
int main () {
std::ofstream myfile("example.txt");
if(myfile.is_open())
{
myfile << "Writing this to a file.n";
myfile << 1 << 2 << 3;
}
else
{
std::cout << "error opening file" << std::endl;
}
return 0;
}
这会在您的工作目录中创建example.txt
(如果它尚不存在(,打开它,流式传输到它并在文件被销毁时关闭myfile
。现在该文件包含以下文本:
Writing this to a file.
123
相关文章:
- 如何读取 TXT 文件并仅将 int 存储在 C 中
- 如何使用 C++ 将测验分数存储在 TXT 文件中
- C++-需要读取存储在文件(.txt)中的时间戳并正确检索
- 将.txt文件存储到 char* 2d 矢量C++中
- C++:从.txt文件中读取复数并存储到复数数组中
- 将数据从 TXT 文件存储到 strucutre 数组中
- 将每行的4个值从TXT文件存储到对象-C 中
- 将 Unicode 字符存储在.txt文件中的新行中
- 在TXT文档的一部分中查找信息并将其存储在变量中
- c++密码存储.txt文件+屏蔽输入
- 如何在Visual C 中读取具有字符(无间距)的TXT文件,并将其存储到2D字符阵列中
- C ++读取TXT文件并将其存储在矩阵字符中
- 有没有一种方法可以防止以前运行的值存储在txt文件中(防止覆盖)
- 如何将输入到txt文件中的数据存储到数组中
- 将 txt 值存储到向量的 <int>c++ 快速方法
- 我应该把从TXT文件中提取的数据存储在哪里,以便以后使用
- C++使用分隔符将数据从txt存储到变量中
- 在 C++ 中将.txt中的数据存储为列向量
- 从文件中提取行.txt然后将单词存储到单独的数组中 |C++
- 创建多个 txt 文件以在 c++ 中存储数据