You are assigning the address of the 6th element of the array Input to the pointer. This is past the end of the array and an invalid index and therefore pointer is now invalid (points to nothing usefull).
using namespace std;
char *pointer; //declare pointer to int[arry]
char Input ; //declare normal int[arry]
pointer = &Input; //assign address of Input to pointer
You are dereferencing the invalid pointer and this is simply the wrong way to accept user input using a pointer. You shouldn't dereference the pointer.
cout << "Enter Input" << endl;
cin >> *pointer; // input value to address pointed to by pointer
You are trying to (had it been pointing to a valid address to begin with) return the address of a local (local to the function it is declared in) variable. When the function exits, this local array is popped off the stack and therefore even if pointer had been assigned correctly in the first place, it would still be pointing to an invalid address.
cout << *pointer << endl;
cout << "worked" << endl;
There are several things you can do:
char GetFunction2(char *pointer)
func2 = *pointer;
cout << func2 << endl;
cout << "Second Function" << endl;
int main ()
char *pointer = GetFunction1();
1) You can declare an array in your main function and pass it into both of your functions as a parameter which in turn will populate said array and then display the contents.
2) You could declare the array in GetFunction1 as static which mean the memory will not be popped off the stack once the function exits. This is not a recommended approach.
3) You can stop using pointers and arrays and such. This is the C++ forum, learn to use a string container instead.
4) You can dynamically allocate space in the GetFunction1 function and return a pointer to that memory.