You have at least three problems: The first is that str is a single string, not an array of strings, that would have been e.g.
char str[20][20];
The second problem is that you apparently try to print the "strings" with scanf.
The third problem is that you are using the array str as it was initialized. Local variables are not initialized, and they values are indeterminate. That means that the contents of str will seem to be random. Using uninitialized local variables, like you do in your first loop, leads to undefined behavior.
One way of fixing (parts) of the code could be like
char strings[20][20];
int i;
for (i = 0; i < 20; ++i)
{
char *p = fgets(strings[i], sizeof(strings[i]), stdin);
if (p == NULL)
break; /* Error reading, or "end of file" */
/* The fgets function can leave the newline in the buffer, remove it */
if (strings[i][strlen(strings[i]) - 1] == '\n')
strings[i][strlen(strings[i]) - 1] = '\0';
}
for (int j = 0; j < i; ++j)
printf("String #%d: '%s'\n", i + 1, strings[i]);
char str[20]is an array ofchars, not stringsforloop for the first time, what's the value ofstr[i]?