title: C++ do structs save variable name values
body: <p>I have the following struct which I call using the <code>Read_Header(FILE * InFile)</code>, do structs in C++ save data just like classes. For instance, can I only call the function <code>Read_Header</code> once to set all the variable names in the struct from main.cpp, then get the values of the variable names just by calling them directly.</p>
  <pre><code>typedef struct RIFF_CHUNCK_DISCRIPTOR {
      char                RIFF[4];        // RIFF Header      Magic header
      int32_t             ChunkSize;      // RIFF Chunk Size  
      int32_t             WAVE[4];        // WAVE Header      
  
  };
  typedef struct CRIF_CHUNCK {
  
      char    Crif[4];
      int32_t Length;
      int32_t CrifCheckSum;
  };
  typedef struct FMT_CHUNCK_DISCRIPTOR {
      char                fmt[4];         // FMT header       
      int32_t             Subchunk1Size;  // Size of the fmt chunk     
      int16_t             EncodingTag;
      int16_t             NumOfChan;      // Number of channels 
      int32_t             SamplesPerSec;  // Sampling Frequency in Hz                             
      int32_t             bytesPerSec;    // bytes per second 
      int16_t             blockAlign;     // 2=16-bit mono, 4=16-bit stereo 
      int16_t             bitsPerSample;  // Number of bits per sample      
      int16_t             AudioFormat;    // PCM = 0 , ADPCM = 2
      int16_t             SmplesPerChan;
  };
  typedef struct FACT_CHUNCK {
      char                fact[4];
      int32_t             FactSize;
      int32_t             dwSampleLength;
  
  };
  typedef struct META_DATA {
      char                    meta[4];
      uint32_t                HeadData;// &lt;length of the head data - 8&gt;
      uint8_t                 Version;
      uint8_t                 Model;
      uint32_t                Serial;
      uint32_t                RecordingNumber;
      uint16_t                ChunkNumber;
      uint32_t                TimeStamp;
      uint32_t                MetadataChecksum;
  
  };
  typedef struct  DATA_SUB_CHUNCK {
      char                Subchunk2ID[4]; // &quot;data&quot;  string   
      int32_t             Subchunk2Size;  // Sampled data length    
  
  };
  typedef struct  CDAT {
      char                cdat[4]; // &quot;data&quot;  string   
      int32_t             CdatCheckSum;  // Sampled data length    
  
  };
  typedef struct  FOOTER {
      char                foot[4]; // &quot;data&quot;  string   
      int16_t             PrevChunckNumb;  // Sampled data length    
      int16_t             NextChunckNumb;
      int32_t             FooterChunckSum;
  
  
  };
  
  </code></pre>
  <pre><code>WORD CWav::Read_Header(FILE* WAVF) {
  
      int HeaderArraySize = 46;
      int* HeaderData = new int[HeaderArraySize];
  
  
      int A = 1;
      while (1) {
  
          HeaderIDSize = fread(&amp;RCD, 1, sizeof(RIFF_CHUNCK_DISCRIPTOR), WAVF);
  
          if (RCD.RIFF[0] == 'R' &amp;&amp; RCD.RIFF[1] == 'I' &amp;&amp; RCD.RIFF[2] == 'F' &amp;&amp; RCD.RIFF[3] == 'F') {
  
              break;
          }
  
          else {
  
              fseek(WAVF, A++, SEEK_CUR);
  
          }
  
      }
      int C = 1;
      int Cpcm = 1;
      while (1) {
          FmtSize = fread(&amp;FCD, 1, sizeof(FMT_CHUNCK_DISCRIPTOR), WAVF);
  
          if (FCD.fmt[0] == 'f' &amp;&amp; FCD.fmt[1] == 'm' &amp;&amp; FCD.fmt[2] == 't') {
              NumOfChanells = FCD.NumOfChan;
              BitsPerSample = FCD.bitsPerSample;
              SampleRate = FCD.SamplesPerSec;
  
              if (FCD.EncodingTag == 0x0001) {
                  PCM = true;
              }
              break;
  
  
          }
          else {
  
              fseek(WAVF, C++, SEEK_SET);
  
          }
      }
  
      int T = 1;
      if (PCM == false) {
          while (1) {
              FactSize = fread(&amp;FactC, 1, sizeof(FACT_CHUNCK), WAVF);
  
              if (FactC.fact[0] == 'f' &amp;&amp; FactC.fact[1] == 'a' &amp;&amp; FactC.fact[2] == 'c' &amp;&amp; FactC.fact[3] == 't') {
  
  
                  break;
  
              }
              else {
  
                  fseek(WAVF, T++, SEEK_SET);
  
              }
  
          }
      }
      int F = 1;
  
      while (1) {
          MetaSize = fread(&amp;MetaD, 1, sizeof(FACT_CHUNCK), WAVF);
  
          if (MetaD.meta[0] == 'm' &amp;&amp; MetaD.meta[1] == 'e' &amp;&amp; MetaD.meta[2] == 't' &amp;&amp; MetaD.meta[3] == 'a') {
  
              SerialNum = MetaD.Serial;
              RecordingNum = MetaD.RecordingNumber;
              break;
  
          }
          else {
  
              fseek(WAVF, F++, SEEK_SET);
  
          }
  
      }
  
      int H = 1;
      while (1) {
  
          DataChunckSize = fread(&amp;DSC, 1, sizeof(DATA_SUB_CHUNCK), WAVF);
          if (DSC.Subchunk2ID[0] == 'd' &amp;&amp; DSC.Subchunk2ID[1] == 'a' &amp;&amp; DSC.Subchunk2ID[2] == 't' &amp;&amp; DSC.Subchunk2ID[3] == 'a') {
  
              break;
          }
          else {
  
              fseek(WAVF, H++, SEEK_SET);
          }
  
      }
  
      Cdata_Postion = 1;
      while (1) {
  
          CdatSize = fread(&amp;CDA, 1, sizeof(DATA_SUB_CHUNCK), WAVF);
          if (CDA.cdat[0] == 'c' &amp;&amp; CDA.cdat[1] == 'd' &amp;&amp; CDA.cdat[2] == 'a' &amp;&amp; CDA.cdat[3] == 't') {
  
              break;
          }
          else {
  
              fseek(WAVF, Cdata_Postion++, SEEK_SET);
          }
  
      }
      int f = 1;
      while (1) {
  
          FootSize = fread(&amp;Footer, 1, sizeof(DATA_SUB_CHUNCK), WAVF);
          if (Footer.foot[0] == 'f' &amp;&amp; Footer.foot[1] == 'o' &amp;&amp; Footer.foot[2] == 'o' &amp;&amp; Footer.foot[3] == 't') {
  
              break;
          }
          else {
  
              fseek(WAVF, f++, SEEK_SET);
          }
  
      }
      BUFFER_SIZE = DSC.Subchunk2Size / (FCD.NumOfChan * (FCD.bitsPerSample / 8));
      return BUFFER_SIZE;
  }
  </code></pre>