使用C 寻求文件

Seeking file using c++

本文关键字:文件 使用      更新时间:2023-10-16
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);
}