I am learning pointers and i tried this following program

```
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
char* getword()
{
    char*temp=(char*)malloc(sizeof(char)*10);
    cin>>temp;
    return temp;
}
int main()
{
   char *a;
   a=getword();
   cout<<a;
    return 0;
}

```

To my level of understanding, `a` is a pointer to a character, and in the function `getword()` I returned `temp` which I think the base `&temp[0]`. I thought that the output would be the first character of the string I enter, but I got the entire string in `stdout`. How does this work?