title: Trouble with fscanf syntax when reading files from file
body: <p>I'm trying to read in data from a file in C. I'm following along with an example video my professor suggested us to watch about using fscanf to read files into memory.</p>
  <p>But I have a problem trying to figure out how to read one string after another with a delimiter in between. In the example video he reads the string in at the end of the line and stops when he hits a '\n' character.</p>
  <p>My fscanf is returning 1 instead of 6 as it should (I think). I believe there's something wrong with my syntax of how I read my first two strings.</p>
  <p>Here are a few lines from my data sheet:</p>
  <pre><code>ggqavxbtdtks|foo|004042|4|3|
  ebsawskolwre|foo|001977|4|2|
  wthbjpvgkgvy|moo|021392|4|1|
  ivftrtsdqwoj|woo|122665|4|1|
  </code></pre>
  <p>Here's the function that reads data into memory.</p>
  <pre><code>// Read file and import data into struct
  int readData(struct Transaction record[], const char filepath[], const int max)
  {
      // Declare Variables
      int amount = 0;
      char ch;
  
      // Declare filepointer
      FILE* fp = fopen(filepath, &quot;r&quot;);
  
      if (fp != NULL)
      {
          while (amount &lt; max &amp;&amp; fscanf(fp, &quot;%30[^|]%*c|%30[^|]%*c|%d|%d|%d|%c&quot;, record-&gt;title, record-&gt;ctg-&gt;category, &amp;record-&gt;amount, &amp;record-&gt;month, &amp;record-&gt;day, &amp;ch) == 6)
          {
              if (ch != '\n')
              {
                  while (fgetc(fp) != '\n');
              }
  
              amount++;
          }
  
          fclose(fp);
          fp = NULL;
      }
      else
      {
          printf(&quot;Cannot read file\n&quot;);
      }
  
      // Return number of participants
      return amount;
  }
  </code></pre>
  <p>Also this is for a personal project, nothing for school. I am just trying to learn new things.</p>