使用C 寻求文件
Seeking file using c++
void Test(Packets& packet)
{
char buf[BUFLEN];
char* offset = buf;
unsigned int foo;
for(;!gzeof(file_handle);){
int len = gzread(file_handle, offset, sizeof(buf)-(offset-buf));
char* cur = buf;
char* end = offset+len;
for (char* eol; (cur<end) && (eol = std::find(cur, end, 'n')) < end; cur = eol + 1)
{
string string_array = string(cur, eol);
if(string_array[0] == 'L'){
packet.foo = blah;
}else{
packet.foo = bar;
}
//After readnig a line.. how do I make sure it quits this function (does another job in some other function) and continous from the next line?
}
#ifdef ROTATION
offset = std::rotate(buf, cur, end);
#else
offset = buf + (end-cur);
std::rotate(buf, cur, end);
#endif
}
std::cout<<std::string(buf, offset) ;
}
readnig a Line ..我如何确保它退出此功能(在其他功能中是否在其他功能中执行另一个作业)并从下一行中进行连续?我试图将BUF置于全局变量,并仅在缓冲区为空时才读取文件。
为什么要退出功能并从下一行继续?
以一个人读取一条线的方式更改您的功能,而另一个则对其进行任何操作
您可能想做类似或我错了的地方?
{
Packets myPacket;
Test(packet);
OtherFunction(packet);
}
相关文章:
- 通过多个头文件使用常量变量
- 生成文件不对文件使用隐式规则
- 两个文件使用彼此的功能-如何解决
- 生成一个生成文件,该生成文件使用Automake在一个步骤中编译和链接所有源文件
- 对同一文件使用 .read 的次数是否有限制?
- 是否有正确的方法对生成文件中的对象文件使用模板命令?(C++)
- 如何在C++中为整个文本文件使用字符串流while循环逻辑
- 如何对继承的文件使用前向声明
- 获取对源文件中特定函数的所有调用并生成其他文件(使用 C、C++预处理器或脚本)
- 从文件(使用strtok()和strcpy())解开数据时进行分割故障
- 在 c++ 中对两个文件使用标头
- 当删除部分依赖列表时,GNU make 对每个对象文件使用相同的源文件
- 如何在文本文件中仅读取一行,该文本文件使用QT具有特定单词
- 我应该只对原始 cpp 文件使用 add_executable() 还是通过 add_library() 创建一个库
- 在 c++ 和 c# 中,对文件容器中包含的文件使用文件路径
- CMD窗口停止工作,文本文件使用fstream读取错误
- 如何在 C++_ 中通过不同目录中的文件使用该变量
- JPEG编码位图(BMP)图像从文件使用libjpeg / C++
- 创建 时出错.SO文件使用Cygwin
- 文件I/O使用C++同时打开两个文件