我要将下面的C语言改写成delphi语言:
  fgets(c_str, 80, wmmdat);
  if (sscanf(c_str,"%lf%s",&epoch,model) < 2) 
   {
       fprintf(stderr, "Invalid header in model file WMM.COF\n");
       exit(1);
   } S3:
  if (fgets(c_str, 80, wmmdat) == NULL) goto S4;/* CHECK FOR LAST LINE IN FILE */
  for (i=0; i<4 && (c_str[i] != '\0'); i++)
    {
      c_new[i] = c_str[i];
      c_new[i+1] = '\0';
    }
  icomp = strcmp("9999", c_new);
  if (icomp == 0) goto S4;
/* END OF FILE NOT ENCOUNTERED, GET VALUES */
  sscanf(c_str,"%d%d%lf%lf%lf%lf",&n,&m,&gnm,&hnm,&dgnm,&dhnm);  if (n > maxord) goto S4;
  if (m > n || m < 0.0) 
    {
      fprintf(stderr, "Corrupt record in model file WMM.COF\n");
      exit(1);
    }  if (m <= n)
    {
      c[m][n] = gnm;
      cd[m][n] = dgnm;
      if (m != 0)
        {
          c[n][m-1] = hnm;
          cd[n][m-1] = dhnm;
        }
    }
  goto S3;
我的改写如下:
 list1:= tstringlist.Create;
  list2:=tstringlist.Create;
  list1.LoadFromFile('WMM.COF');
  list2.Delimiter:=' ';
  list2.DelimitedText:=list1.Text;
  list1.Free;
  for i:=0 to 5 do
  u[i]:=strtofloat(list2.Strings[i]);
  list2.Free;
 S3:
  if (floattostr(u[i])= '') then goto S4;
   if (floattostr(u[i]) <> '') then
   begin
     for i:=0 to 3  do
      BEGIN
      c_new[i] := floattostr(u[i]);
    c_new[i]:= '';
      END;
     n:=u[0];
     m:= u[1];
     gnm:= u[2];
     hnm:= u[3];
     dgnm:= u[4];
     dhnm:= u[5];     if m <= n then
       begin
      c[m][n] := gnm;
      cd[m][n] := dgnm;
      if (m <> 0)  then
            begin
          c[n][m-1] := hnm;
          cd[n][m-1] := dhnm;
          end;
        end;
   end;
  if c_new[i]=9999 then goto S4;
     goto s3;
但是我发现对于类型的选择上出现了问题,我改了很多类型,但还是有问题。
floattostr(u[i]) <> ''
  c_new[i] := floattostr(u[i]);
    c_new[i]:= '';
  if c_new[i]=9999 then goto S4;
就这四条常出现某一条的错误。
希望delphi高手们能帮我改改,给我点想法。万分感谢大家。