title: Using Delimiters for 'fscanf' in c
body: <p>I am trying to read a file in C in a way that it would load simple variables and values. For example, let's say this is the text of the file:</p>
  
  <pre><code>a=100
  b=hello
  c=world
  </code></pre>
  
  <p>ow the idea would be to load each line of the file such that the string on the left of the equals sign would be the name of the variable, and the string on the right would be loaded in as the value. This is the code that would read the file in the way I described:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  {
      FILE* f;
      f = fopen("test.txt", "r");
  
      char name[256];
      char value[256];
  
      while(fscanf(f, "%255[^=]=%255[^=]", name, value) == 2)
          printf("%s, %s\n", name, value);
  
      return 0;
  }
  </code></pre>
  
  <p>But when I compile and run it, all I get as the output is:</p>
  
  <pre><code>a, 100
  b
  </code></pre>
  
  <p>I should mention I have only a very basic grasp of how delimiters work in <code>scanf</code> or <code>fscanf</code> for the formatting strings. I have a feeling that's what's going wrong here, but I have yet to find or stumble upon a solution. Any help would be appreciated! </p>