# Read only first word of line from line with $fscanf()

**URL:** <https://verificationacademy.com/forums/t/read-only-first-word-of-line-from-line-with-fscanf/31324>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, fscanf\
**Created:** [December 17, 2015, 8:20am UTC](https://verificationacademy.com/forums/t/read-only-first-word-of-line-from-line-with-fscanf/31324 "2015-12-17T08:20:31Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ayehia](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/ayehia/32/2099_2.png) [@ayehia](https://verificationacademy.com/forums/u/ayehia)\
**Post date:** [December 17, 2015, 2:06pm UTC](https://verificationacademy.com/forums/t/read-only-first-word-of-line-from-line-with-fscanf/31324/4 "2015-12-17T14:06:51Z")

</div>

_In reply to [Vaino](https://verificationacademy.com/forums/t/read-only-first-word-of-line-from-line-with-fscanf/31324/3):_

Then what you want is something like:

```verilog

      string line;
      string first_word_column [];
      fd = $fopen ("myfile.txt", "r");
      while (!$feof(fd)) begin
          code = $fgets (line, fd); //Get entire line
          code = $sscanf (line, "%s", first_word_column[i]); //Get first word of that line
          i++;
      end
      $fclose (fd);

```

---

_[View the full topic](https://verificationacademy.com/forums/t/read-only-first-word-of-line-from-line-with-fscanf/31324)._
