title: how to read a text file in c and then split each line into tokens?
body: <p>The input text file has some numbers per line, numbers are split by space. The first two lines only got one number, and the following lines got three. What I want to do is read each line of the input and store these numbers.</p>
  
  <p>This is what I've got so far:</p>
  
  <pre><code>    int
      main(int argc, char *argv[]) {
          int n = 0;
          char buff[MAX_STRING_LEN]; //MAX_STRING_LEN is defined as 64
          while (fgets(buff,MAX_STRING_LEN, stdin) != NULL) {
              char temp;
              if (n == 0) {
                  sscanf(buff, "%s", &amp;temp);
                  int h_num = (int)temp;
              } else if (n == 1) {
                  sscanf(buff, "%s", &amp;temp);
                  int s_num = (int)temp;
              } else {
                  sscanf(buff, "%s", &amp;temp);
                  char *token;
                  token = strtok(&amp;temp, " ");
                  int i = 0;
                  int a,b,c;
                  while (token != NULL) {
                      if (i == 0) {
                          a = (int)token;
                          token = strtok(NULL, " ");
                      } else if (i == 1) {
                          b = (int)token;
                          token = strtok(NULL, " ");
                      } else {
                          c = (int)token;
                          token = strtok(NULL, " ");
                      }
                      i++;
                  }
              }
              n++;
          }
          return 0;
      }
  </code></pre>
  
  <p>The print statement I used to test my code is like:</p>
  
  <pre><code>    printf("%d\n",h_num);
      printf("%d\n%d\n%d\n",a,b,c);
  </code></pre>
  
  <p>I created a text file like this:</p>
  
  <pre><code>23
  34
  4 76 91
  </code></pre>
  
  <p>but the output is not what I expected, it's the address of the pointer I think. (I'm stuck with pointer again =( )
  Could someone help me to point out what the problem is? Appreciate it. </p>