Your variable char **global; is a disaster zone. It is a null pointer. It must be made to point to some valid data before it can be used. It is a double pointer, in fact, so you have to make space available like this:
char array[1000];
char *pointer = array;
char **global = &pointer;
Now you could safely use global[0].
Inside the function, you pass &global to scanf(); that is a char ***. Being a 'Three-Star Programmer' is not a good thing, especially when you do it by accident and not by design.
You include the header <string.h> but don't use any of its functions. You do use functions from <stdio.h> and you don't include that. Technically, you invoke undefined behaviour by using the variadic functions printf() and scanf() without a function prototype in scope. The compiler is entitled to be told about functions that take a variable number of arguments (that's what 'variadic' means), and is entitled to miscompile code where it is not told that the function is variadic.
Assuming you really do need a global variable at all (they're generally not a good idea and you should avoid using them as much as possible), then you could reasonably write:
#include <stdio.h>
char global[1000];
int main(void)
{
printf("Please Enter Text: ");
if (scanf("%s", global) == 1)
printf("%s\n", global);
return 0;
}
This is at least sound code, but it still has your original problem that it reads only one word, not a whole line.
Forget that gets() exists. It was one of the buggy functions used in the first Internet Worm of 1988 (Google for 'morris internet worm'). It is irredeemable; it cannot be used safely in a hostile environment, and all programming has to be done assuming a hostile environment.
To read a line, use fgets().
#include <stdio.h>
#include <string.h>
char global[1000];
int main(void)
{
printf("Please Enter Text: ");
if (fgets(global, sizeof(global), stdin) != NULL)
{
size_t len = strlen(global);
if (len != 0 && global[len-1] == '\n')
global[--len] = '\0';
printf("%s\n", global);
}
return 0;
}
This gets a line of data into global.
You can legitimately ask how len could ever be zero (I asked it of myself, and I replaced assert(len != 0) because of the answer). One answer would be 'standard input was redirected from a binary file and the first byte was a null (zero) byte'. Then fgets() would read data including the null byte up to the first newline, but the strlen() would stop at the null byte, reporting 0 as the length.
The code removes the newline from the string, and determines its length at the same time — you normally need that length. It then prints it. Notice that the code checks that fgets() succeeded. I/O (especially input) has a habit of breaking when you aren't looking. A lot of the time, it will work fine, but to make your program robust, you have to be paranoid about input operations failing (and, later, memory allocations failing).
printf&,globalis still a pointer to acharpointer. If it points at valid data structures, then*globalwould give achar *that could be printed with%s.