title: Problems with struct
body: <p>so i was having two types of issues from my code... the general forms are:</p>
  
  <p>"left of ... must have class/struct/union " :</p>
  
  <pre><code>                      doc.id[j] = NULL;
                        doc.ISBN[j] = NULL;
                        doc.title[j] = NULL;
                        doc.year[j] = NULL;
  </code></pre>
  
  <p>and " 'doc' uses undefined struct 'main::m_doc'"</p>
  
  <pre><code>struct m_doc doc;
  </code></pre>
  
  <p>while the struct m_doc doc is included in the top of each function .</p>
  
  <p>here is my struct :</p>
  
  <pre><code>struct m_doc{
  
      char id[30];
      int ISBN[30];
      char title[50];
      char author[50];
      int year[30];
  };
  </code></pre>
  
  <p>my fist function :</p>
  
  <pre><code>void menudoc()
  {   struct m_doc doc;
      int c = 0, a = 0, b;
      cout &lt;&lt; "1. Them tai lieu moi" &lt;&lt; endl;
      cout &lt;&lt; "2. Xoa tai lieu" &lt;&lt; endl;
      cout &lt;&lt; "3. Bao cao theo nam xuat ban" &lt;&lt; endl;
      cout &lt;&lt; "0. Tro lai menu truoc" &lt;&lt; endl;
      cout &lt;&lt; "Ban chon:";
      cin &gt;&gt; b;
      switch (b)
      {
      case 1:
      {
                for (int i = 0;; i++)
                {
                    if (doc.id[i] == NULL &amp;&amp; doc.ISBN[i] == NULL &amp;&amp; doc.title[i] == NULL &amp;&amp; doc.author[i] == NULL &amp;&amp; doc.year[i] == NULL)
                    {
                        i = c; break;
                    }
                    else continue;
                }
                cin &gt;&gt; doc.author[c] ;
                cin &gt;&gt; doc.id[c] ;
                cin &gt;&gt; doc.ISBN[c] ;
                cin &gt;&gt; doc.title[c];
                cin &gt;&gt; doc.year[c];
                for (int i = 0;; i++){
                    for (int j = 1;; j++){
                        if (doc.id[i] == doc.id[j]){
                            doc.author[j] = NULL;
                            doc.id[j] = NULL;
                            doc.ISBN[j] = NULL;
                            doc.title[j] = NULL;
                            doc.year[j] = NULL;
                        }
                        if (doc.year[i]&lt;1000 || doc.year[i]&gt;9999){
                            doc.author[i] = NULL;
                            doc.id[i] = NULL;
                            doc.ISBN[i] = NULL;
                            doc.title[i] = NULL;
                            doc.year[i] = NULL;
                        }
                    }
                }
                break;
      }
  
  
      case 2:
      {
                int x;
      char docid[50];
      cout &lt;&lt; "IDDOC: ";
      cin &gt;&gt; docid[50];
      cout &lt;&lt; "\n";
      for (int i = 0;; i++){
          if (docid[50] == doc.id[i]) {
              doc.author[i] = NULL;
              doc.id[i] = NULL;
              doc.ISBN[i] = NULL;
              doc.title[i] = NULL;
              doc.year[i] = NULL;
              x++;
          }
  
      }
      if (x == 0) cout &lt;&lt; "IDDOC khong ton tai." &lt;&lt; endl;
      break;
      }
      case 3:
      {
                int yeardoc[50];
      cin &gt;&gt; yeardoc[50];
      for (int i = 0;; i++){
          if (yeardoc[50] == doc.year[i])
              write_output(i, "report.scv");
  
      }
      break;
      }
      case 0:
      {
                menubegin();
                break;
      }
          menudoc();
      }
  </code></pre>
  
  <p>}</p>
  
  <p>my second function :</p>
  
  <pre><code>int write_output(int i, char* filename){
      ios::out;
      struct m_doc doc;
      // open file for output
      ofstream fout(filename);
      char * k, *h;
      k = strchr(doc.title, ',');
      h = strchr(doc.author, ',');
      if (k != 0 &amp;&amp; h != 0)fout &lt;&lt; doc.id[i] &lt;&lt; "\n" &lt;&lt; doc.ISBN[i] &lt;&lt; "\n" &lt;&lt; '"' &lt;&lt; doc.title[i] &lt;&lt; '"' &lt;&lt; "\n" &lt;&lt; '"' &lt;&lt; doc.author[i] &lt;&lt; '"' &lt;&lt; "\n" &lt;&lt; doc.year[i] &lt;&lt; endl;
      if (k != 0) fout &lt;&lt; doc.id[i] &lt;&lt; "\n" &lt;&lt; doc.ISBN[i] &lt;&lt; "\n" &lt;&lt; '"' &lt;&lt; doc.title[i] &lt;&lt; '"' &lt;&lt; "\n" &lt;&lt; doc.author[i] &lt;&lt; "\n" &lt;&lt; doc.year[i] &lt;&lt; endl;
      if (h != 0)fout &lt;&lt; doc.id[i] &lt;&lt; "\n" &lt;&lt; doc.ISBN[i] &lt;&lt; "\n" &lt;&lt; doc.title[i] &lt;&lt; "\n" &lt;&lt; '"' &lt;&lt; doc.author[i] &lt;&lt; '"' &lt;&lt; "\n" &lt;&lt; doc.year[i] &lt;&lt; endl;
      // write informations
      if (k == 0 &amp;&amp; h == 0)fout &lt;&lt; doc.id[i] &lt;&lt; "\n" &lt;&lt; doc.ISBN[i] &lt;&lt; "\n" &lt;&lt; doc.title[i] &lt;&lt; "\n" &lt;&lt; doc.author[i] &lt;&lt; "\n" &lt;&lt; doc.year[i] &lt;&lt; endl;
  
      // close file
      fout.close();
  
  
      return 0;
  }
  </code></pre>
  
  <p>anybody im asked said that it was something about scope but none of them know the problem since everything looks fine... please help me , every help is much appreciated :)   </p>