Question: Hello I wrote this code for following question:
Write a C program that reads a text file into an array of character. You may assume that the file contains no more than 1000 characters. But code prints only first character of text. Where do I make mistake? 

```
FILE *wse;
char a[1000];
int i;

    wse=fopen("21e.txt","r");

    for(i=0;i!=100;i++);
    {
    fscanf(wse,"%c",&a[i]);
    printf("%c",a[i]);
    }

```

Answer: 
Your code has a *logical* error which makes it broken - very easy to fix.

* Your for loop has *empty body* - that's why it only prints the first character. *Semicolon* deleted.

There is also a style issue in checking the value of the counter:

* Although *checking* `i` against *not* being `100` won't make your code fail if everything else is OK, it's more common and conforming to your task specification to check its value for being *less than* `100`, or whichever constant you want.

Although this may not be the most elegant way of completing such a task, it's a rework of your read-by-character method code:

```
#include <stdio.h>

int main(void)
{
 FILE *wse;
 char a[1000];
 int i;

  if((wse=fopen("3.txt","r")) == NULL)//always check for file errors!
      return 1;

  for( i=0 ; i<100 ; i++ )
  {
      if(fscanf(wse,"%c",&a[i]) != 1) //check against end of file!
          break;
      printf("%c",a[i]);
  }
  fclose(wse);
 return 0;
}

```
Just use `fgetc` and `putchar`, since you are reading character-by character

```
int c;
while ((c = fgetc(fp)) != EOF)
    putchar(c);

```

Also, check the return value of `fopen`. It returns a `NULL` on failure.