且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用C解析文本文件

更新时间:2023-02-25 23:04:17

您应在每个循环中检查行尾条件,例如:

You should check the end of line condition in every loop, for instance:

Poonamol写道:
Poonamol wrote:

while(pLine [i]&& pLine [i]!=''''&& pLine [i ]!=''\ t''&&
pLine [i]!='';''&& pLine [i]!=``#'')
{i ++; }

while (pLine[i] && pLine[i] != '' '' && pLine[i] != ''\t'' &&
pLine[i] != '';'' && pLine[i] != ''#'')
{ i++; }



会变成



would become

while (pLine[i] && pLine[i] != ' ' && pLine[i] != '\t' &&
         pLine[i] != ';' && pLine[i] != '#')
  {
    if ( pLine[i] == '\n') return 0;
    i++;  
  }



:)



:)


非常感谢您的回复.
我知道每一行的数据限制.
因此,如果strlen(pLine)小于限制或大于限制,那么我正在打印错误.
这对我来说可以. :-O
Thank you so much for the reply.
I know the data limit for each line.
So if strlen(pLine) is less than limit or greater than limit then I am printing error.
It works fine for me. :-O