Question: I am trying to scan in some user input, but when I run the program, all I get is a bunch of 3/4 fractions.

I need to be able to scan in characters, spaces and break lines. If a user enters something like:

```
Hello this
  is
     a test123 234     !!!

```

Once they are done entering what they want to enter, they will press CTRL+D, and that is how I will know to stop reading what they are saying.

Here is my code:

```
char user_input[1000];
int i = 0;
    while (scanf("%c", &user_input[i]) == 1) {
        i++;
}

```

Answer: 
Your code is ok. The following program:

```
#include <stdio.h>

int main()
{
    char user_input[1000];
    int i = 0;
    while (scanf("%c", &user_input[i]) == 1) {
        i++;
    }
    user_input[i] = '\0';
    printf("%d\n", i);
    printf("%s", user_input);
    return 0;
}

```

Produced with your input the following:

```
42
Hello this
  is
     a test123 234     !!!

```

However `scanf` is generally used to `scan formatted` input. I would advise to read one character at a time using `getchar()` or `fgets()`

```
int main(void) {
   char user_input[1000];
   int i = 0;
   int temp;
   while ((temp = getchar()) != EOF) {
        user_input[++i] = temp;
   }
   user_input[i] = '\0';
}

```
To have more control over the user input, you could read the user input character by character with [getchar()](https://linux.die.net/man/3/getchar), it will return EOF when the user enters CTRL-D, usually. After that, the string can be parsed to extract the entered fractions and the like.

If you you'd still like to use something like scanf(), you might consider to replace it with a call to [fgets()](https://linux.die.net/man/3/fgets), to prevent buffer overflows. [Or use scanf() with an appropriate formatting string](https://en.wikipedia.org/wiki/Scanf_format_string#Usage) (*with a specified maximum number of characters*).

```
    /* gcc -o test_getchar test_getchar.c  && ./test_getchar */

    #include <stdio.h>

    int main()
    {
        char user_input[1000] = {0};
        int i = 0;
        char c;
        while ((c = getchar()) != EOF) {
            /* do something with c here... */
            user_input[i] = c;
            ++i;
            if (i >= sizeof(user_input)-1)
                break;
        }
        user_input[i] = 0;
        printf("user input: %s\r\n", user_input);
        return 0;
    }

```