Skip to content

rewind edited

muneebullashariff edited this page Jan 4, 2024 · 4 revisions
   module file_eof;
   int fd;
   string str;
   int dummy;

   initial begin:BEGIN_I

    //open the file in the write mode
    fd = $fopen ("hihihi.sv", "w+");

    //displays the contents into the file
    $fdisplay(fd,"teams");

    $fdisplay(fd,"c");

    dummy = $rewind(fd);

     $fdisplay(fd,"abcde");


     //close the file
     $fclose(fd);

     //open the file in read mode
     fd = $fopen("hihihi.sv","r");
     dummy = $feof(fd);
     $display("EOF=%0d",dummy);
     repeat(3) begin
     dummy = $fgets(str,fd);

    $display("line:%0s",str);
    end
    dummy=$feof(fd);
    $display("EOF=%0d",dummy);
    $fclose(fd);

    end:BEGIN_I

    endmodule:file_eof

Screenshot from 2023-07-28 12-41-14

image

Clone this wiki locally