text: I am completely new to programming. Im currently working out of 'C++ without fear' by Brian Overland as it is recommended on this site as the first book in a sequence to learn c++. I have an idea for a game I want to design, and after each of the exercises in the book I try to take what I learned and make a small program with characteristics similar to something I might do in the program. This extremely simple program crashes right after input. This is what I am trying to do:
  1. Declare an array of strings with 1 element
  2. Call a function to get the user to input a name into the first(and only) element of a local array of strings
  3. Have that function return the value of the first element of that array
  4. Assign the value of that element to the first element of the array declared in step 1
  5. For testing purposes, output the value of that element.
  While typing this out, a couple things occurred to me. I could just pass by reference the address of that first element, assign the value to that address and then change that function to a void function right? Further, since I am just using one element of an array of strings, I could just use a string, instead of an array, right? However, this isnt ultimately what I want to do and I will be using more elements once I get beyond this utter newb stage. All of this aside, the fact that this simple program keeps crashing despite no compiler warnings (devc++) is annoying me, b/c its obviously something Im doing thats completely wrong. Anyways, here is the code.
  Code:
  #include <iostream>
  #include <ctype.h>
  using namespace std;
  char getname ();
  int main(){
  char *name[1];
  *name[0]=getname ();
  cout<<name[0];
  cin>>*name; //COMMENT - this is just to pause the output so I can see it
  }
  char getname (){
  char *name[1];
  cout<<"Enter your name: ";
  cin.getline(name[0],15);
  return *name[0];
  }