>So they are basically the same.
I'd better point here again.
>So can I use the first and the second for fgets()?
Not unless you allocate memory to where these pointers point.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char automatic[10];
char *dynamic;
size_t size = 42;
puts("Enter 'automatic' string:");
fflush(stdout);
if(fgets(automatic, sizeof automatic, stdin) != NULL)
{
printf("automatic: %s\n", automatic);
}
dynamic = malloc(size);
if(dynamic != NULL)
{
puts("Enter 'dynamic' string:");
fflush(stdout);
if(fgets(dynamic, size, stdin) != NULL)
{
printf("dynamic: %s\n", dynamic);
}
free(dynamic);
}
return 0;
}
/* my output
Enter 'automatic' string:
All work and no play makes Jack a dull boy.
automatic: All work
Enter 'dynamic' string:
dynamic: and no play makes Jack a dull boy.
*/