title: Reading combinations of string and integer from file in C
body: <p>I am novice to C langugage, so please bear with me. I've tried to read a file which contains strings but output obtained is single character.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;malloc.h&gt;
  
  #define CALLOC(num, type) ((char*)calloc (num, sizeof(char)))
  #define FREE(addr) (free((void*) (addr)))
  
  int i, count;
  char *x, *y, *z;
  
  int main (void) 
  
  {
  
  FILE *stream;
  if ( (stream = fopen ( "test.txt", "r" )) == NULL )
  { printf ("Cannot read the new file\n");
  exit (1);
  }
  
  count = 3;
  
  x=CALLOC(count, char);
  y=CALLOC(count, char);
  z=CALLOC(count, char);
  
  
  for ( i=0; i&lt;count; i++ ) 
  { fscanf (stream,"%c %c %c", &amp;x[i], &amp;y[i], &amp;z[i]);
  printf ("\n %d %c %c %c ", i, x[i], y[i], z[i]);
  }
  
  FREE(x);
  FREE(y);
  FREE(z);
  
  fclose (stream);
  
  }
  </code></pre>
  
  <p>Input test.txt file contains</p>
  
  <pre><code>1 ab 1
  2 aa 5
  1 cc 1
  </code></pre>
  
  <p>current output</p>
  
  <pre><code> 0 1 a b
   1   1 2
   2   a a 
  </code></pre>
  
  <p>Expected output</p>
  
  <pre><code> 0 1 ab 1
   1 2 aa 5
   2 1 cc 1
  </code></pre>
  
  <p>I doubt whether I should use a character array but it seems not working and I feel reading a int using char is acceptable. Here I require the expected output, for this any method/suggestion is appreciated.</p>