只读某一行
Read in a certain line only?
我正在制作一个程序来读取配置文件,我只想读取某些行。例子:
config.txt:
This is a test configuration text file
It isn't supposed to read this line or the line above it
Read this line, but not the white space above or below it
Don't read this line or the white space above or below it
Read this line, but not the white space above or below it
我正在使用您的基本I/O:
FILE *File;
File = fopen("config.txt", "r");
你可以用一些字符或数字标记你不想读的行,所以当输入流读取它时,你可以跳过它。
0这是一个测试配置文本文件0不应该读取这一行或它上面的行
1读这一行,但不读它上面或下面的空白
0不要读这一行或它上面或下面的空白
0读这一行,但不读它上面或下面的空白
然后检查每一行的第一个位置的值并跳过它/读取它。或者使用类似C中的多行注释/*注释掉*/检查开始字符并跳过结束字符之前的所有内容。
相关文章:
- 用c++从输入文件中读取另一行
- 读取文件的最后一行并输入到链接列表时出错
- 我正在使用嵌套的while循环来解析具有多行的文本文件,但由于某种原因,它只通过第一行,我不知道为什么
- 从C++dll访问C#中的一行主要参数
- 在C++中,我如何接受不同于同一行的用户输入
- 如何从一行中读取特定数量的字符?(C++)
- 非常量变量只读位置的赋值
- 是否可以在C++中使变量真正只读
- 读取最后一行代码算法 - c++ 时出现问题
- 查找矩阵C++中每一列和每一行的最小和最大元素
- 有没有办法在一行中填充矢量图
- 需要将一行代码从C++ Qt翻译成PyQt
- 犰狳C++ - 从常量内存初始化只读矩阵而不复制
- 为什么如果我添加这一行,我的程序会不断询问值
- 我无法在Visual Studio代码中使用CIN输入答案,它说输入您的年龄,但它说只读文本编辑器如何解决这个问题?
- 以只读模式打开数据库时SQLITE_CANTOPEN错误
- 如何使代码打印文本文件中的第一行?
- 如何在C++中以这种方式返回一行文本?
- 如何在QPlainTextEdit中使一行只读
- 只读某一行