Question: How can enter two strings with scanf in C?, I want to use them as follow:

```
#include <stdio.h>
#include <string.h>
main()
{
  char kid[25];
  char color[10];
  scanf( "%24[^\n]", kid); // kid name
  scanf( "%9[^\n]", color);
  printf("%s\'s favorite color is %s.\n", kid, color);
  return 0;
}

```

Answer: 
You are reading input till a `\n` into `kid` with the first `scanf()`. But that `scanf()` won't read the `\n` and it will remain in the input buffer.

When the next `scanf()` is done, the first character it sees is the `\n` upon which it stops reading before anything is written to `color`.

You could do

```
scanf("%24[^\n] ", kid);
scanf("%9[^\n]", color);

```

The space after the `[^\n]` will read a white-space character like `\n`.

If `%*c` is used like

```
scanf("%24[^\n]%*c", kid);

```

`%*c` in `scanf()` will cause a character to be read but it won't be assigned anywhere. `*` is the assignment suppressing character. See [here](https://stackoverflow.com/q/34874347/5375464).

But if exactly 25 characters are given as input before a `\n`, the `%*c` will just read the last character leaving the `\n` still in the input buffer.

If you can use a function other than `scanf()`, `fgets()` would do well.

Do

```
fgets(kid, sizeof(kid), stdin);

```

but remember that `fgets()` would read the `\n` as well into `kid`. You could remove it like

```
kid[strlen(kid)-1]='\0';

```

Due to this `\n` being read, the number characters that are read will be effectively 1 less.
Your problem is that this line does not read the `\n` character from the stream.

```
scanf( "%24[^\n]", kid); // kid name

```

So you read the kids name but don't remove the newline character. So the next `scanf()` just sees a return character on the input stream and thus you will get an empty color.

```
if (scanf( "%24[^\n]", kid) == 1) { // kid name
    char term;
    while ( scanf( "%c", &term) == 1 && term != '\n') {
        /* read characters until you can't read or you reach the end of line */
    }
}
else {
    /* Error */
}

```

If the user input a kids name longer than 24 characters then you need to read and throw away these characters (or do some appropriate error handling). The end of the kids name is marked by the `'\n'` character.

Note: The while loop above is for illustration purposes. There are better way.

```
if (scanf( "%24[^\n]", kid) == 1) { // kid name
   scanf("%*[^\n]");  // Note. You can not use "%*[^\n]\n". This will fail if just a newline
   scanf("\n");       // So split into two lines (the first may read nothing).
}
else {
    /* Error */
}

```