title: garbage value return by struct function
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  typedef struct{
  
      char sharePath[100];
      char logPath[100];
      char motd[100];
  
  }pathName_t;
  
  void readConfig(const char *config){ 
      FILE *fp = fopen(config, "r");
      pathName_t pathpath;
      int line = 0;
      int index = 0;
      int c;
      c = getc(fp);
  
      while( c != EOF){
  
      if( c != '\n' ){  //if c not equal to new line, loop through the entire line
         if( line == 0 ){  //line = 0
         pathpath.sharePath[index] = c;
            }else if( line == 1 ){  //line = 1
            pathpath.logPath[index] = c;
               }else{  //line = 2
               pathpath.motd[index] = c;
               }
               index++;
      }else{  //if c equal to new line, replace \0 from \n to the end of string
         if( line == 0 ){  //line = 0
         pathpath.sharePath[index] = '\0';
            }else if( line == 1 ){  //line = 1
            pathpath.logPath[index] = '\0';
               }else{  //line = 2
               pathpath.motd[index] = '\0';
               }
          index = 0;
          line++;
      }  // else close
      c = getc(fp);
  }  //while loop close
      fclose(fp);
  }  //readConfig() close
  
  
  
  int main(){
  
      pathName_t pathName;
      readConfig("settings.config");
      printf("%s", pathName.motd);
      printf("%s",pathName.sharePath);
  }
  </code></pre>
  
  <p><strong>This is the result i get: �z���</strong></p>
  
  <p>I'm intended to create a function to read and retrieve path name store in   this file in multiple line, end up the struct compiled but the result seems goes wrong.. Or any of you have suggestion is there any other method to read contents from a file and have a multiple return value?  </p>