view test/octave.test/io/file-pos-1.m @ 5431:6ddb5a7f399e

[project @ 2005-08-29 20:48:29 by jwe]
author jwe
date Mon, 29 Aug 2005 20:48:52 +0000
parents 0ad1a978082a
children
line wrap: on
line source

nm = tmpnam ();
id = fopen (nm, "wb");
if (id > 0)
  fprintf (id, "%d\n", 1:100);
  fclose (id);
  id = fopen (nm, "rb");
  if (id > 0)
    for i = 1:101
      fgets (id);
    endfor
    if (feof (id))
      fclose (id);
      id = fopen (nm, "rb");
      pos_one = ftell (id);
      s_one = fgets (id);
      for i = 1:48
	s = fgets (id);
      endfor
      pos_fifty = ftell (id);
      s_fifty = fgets (id);
      fseek (id, pos_one, SEEK_SET);
      s_one_x = fgets (id);
      fseek (id, pos_fifty, SEEK_SET);
      s_fifty_x = fgets (id);
      if (s_one == s_one_x && s_fifty == s_fifty_x)
	frewind (id);
	s_one_x = fgets (id);
	if (s_one == s_one_x)
	  printf ("ok\n");
	endif
      endif
    endif
  endif
endif
unlink (nm);