Hi, I'm relatively new to C and have created my first propper programme. The programme works as required but I now want to add a Username system where the user types their name in at the beggining and this then becomes the name used throughout the programme.

This is the base code that I have got working:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define North=0
#define East=1
#define South=2
#define West=3
int GetDirection (int RoomNumber);
void DescribeRoom (int Fig);
void DescribeExit (int Fig);
void SetupRooms();
typedef struct{
  char RoomName[50];
  char Description[400];
  char Description2[400];
  unsigned int Exit[4];
}Location;
Location Room[15];
//Main function
void main(){
 unsigned int RoomNumber = 15; 
 unsigned int Direction;
 SetupRooms();
  while(1){
  
   system("cls");
   DescribeRoom(RoomNumber);
   DescribeExit(RoomNumber);
   Direction = GetDirection(RoomNumber);
   if(Direction==99)exit(0);
   if(Direction>0)RoomNumber= Direction;
  else
  {
   printf ("\nInvalid entry\n");
   for (long i=0; i<5e8; i++);   // Tony's code
  }
 }
}
//DescribeRoom Function
void DescribeRoom (int Fig){
printf("Currently possition: ");
printf(Room[Fig].RoomName);
printf(Room[Fig].Description);
printf(Room[Fig].Description2);
}

//DescribeExit Function
void DescribeExit (int Fig){
 printf("\n\nHe could go to any of the following places...\n");
 printf("\n--------------------------------------------------------------------\n");
 if(Room[Fig].Exit[North]!=0) printf ("\n(N) To the North he sees the %s",Room[Room[Fig].Exit[North]].RoomName);
 if(Room[Fig].Exit[East]!=0) printf ("\n\n(E) East is the %s",Room[Room[Fig].Exit[East]].RoomName);
 if(Room[Fig].Exit[South]!=0) printf ("\n\n(S) Looking South is the %s",Room[Room[Fig].Exit[South]].RoomName);
 if(Room[Fig].Exit[West]!=0) printf ("\n\n(W) Going West will take him to the %s",Room[Room[Fig].Exit[West]].RoomName);
 printf("\n\n--------------------------------------------------------------------");
 printf("\n\n\nJust type the first letter of the direction or press 'Q' to quit."); 
}

//GetDirection Function
int GetDirection(int Fig)
{
 char test;
 unsigned int NewDirection=0;
 while(1)
 {
  test=getch();
  if(test=='n') NewDirection=Room[Fig].Exit[North];
  if(test=='e') NewDirection=Room[Fig].Exit[East];
  if(test=='s') NewDirection=Room[Fig].Exit[South];
  if(test=='w') NewDirection=Room[Fig].Exit[West];
  if(test=='q') NewDirection=99;
  
  if(NewDirection!=0) return(NewDirection);
  printf("\n\nYou cannot go that way, there must be another path to take.");
 }
}
void SetupRooms(){
//ROOM 1
strcpy(Room[1].RoomName, "Outside");
strcpy(Room[1].Description, "\n\nHis eyes slowly rested back upon the house. Its unkept walls wore a thin green\ncoat of algae.");
strcpy(Room[1].Description2, "\nThe trees produced shadows, dancing along the empty flower beds as a slow wind\nkissed the top of the branches. It looked sorry, lonely, friendly.\n\n");
Room[1].Exit[North]=2;  
Room[1].Exit[East]=0;  
Room[1].Exit[West]=0;  
Room[1].Exit[South]=0;  
//ROOM 2
strcpy(Room[2].RoomName, "Entrance");
strcpy(Room[2].Description, "\n\nHe was greeted by a wide staircase, covered in what would have been a plush,\nwhite carpet.");
strcpy(Room[2].Description2, "\nHis eyes were drawn up the stairs but his better judgment told him to look\naround the ground floor first.\n\n");
Room[2].Exit[North]=7;  
Room[2].Exit[East]=4;  
Room[2].Exit[West]=3;  
Room[2].Exit[South]=1;  
//ROOM 3
strcpy(Room[3].RoomName, "Office");
strcpy(Room[3].Description, "\n\nHe slowly edged the door open, his left hand resting on the top of the blade\nhanging naturally off his hip.");
strcpy(Room[3].Description2, "\nThe chair lay helplessly on the floor, paper strewn around its base. The room\nbore nothing of interest.\n\n");
Room[3].Exit[North]=0;  
Room[3].Exit[East]=2;  
Room[3].Exit[West]=0;  
Room[3].Exit[South]=0;  
//ROOM 4
strcpy(Room[4].RoomName, "Small Hallway 1");
strcpy(Room[4].Description, "\n\nOn the other side of the hallway he came across two doors. The one to his left\nwas ajar, the other closed tightly.");
strcpy(Room[4].Description2, "\nThe small hallway brought him a feeling of both comfort and clostrophobia.\n\n");
Room[4].Exit[North]=5;  
Room[4].Exit[East]=6;  
Room[4].Exit[West]=2;  
Room[4].Exit[South]=0;  
//ROOM 5
strcpy(Room[5].RoomName, "Downstairs Bathroom");
strcpy(Room[5].Description, "\n\nThe room was the same as the day it was left. It was not big, or luxurious, but instead a reminder of what had been.");
strcpy(Room[5].Description2, "\nHe spent a minute searching the shelves, but a man in his position found little use for aftershave.\n\n");
Room[5].Exit[North]=0;  
Room[5].Exit[East]=0;  
Room[5].Exit[West]=0;  
Room[5].Exit[South]=4;  
//ROOM 6
strcpy(Room[6].RoomName, "Downstairs Bedroom");
strcpy(Room[6].Description, "\n\nThe cream walls adorned with posters, pictures and memories all suggested that\nof a youth");
strcpy(Room[6].Description2, "\nA double bed lay half dressed with belongings hurriedly strewn across it.\nMusical instruments, a guitar, a drum set.\n\n");
Room[6].Exit[North]=0;  
Room[6].Exit[East]=0;  
Room[6].Exit[West]=4;  
Room[6].Exit[South]=0; 
//ROOM 7 
strcpy(Room[7].RoomName, "Landing");
strcpy(Room[7].Description, "\n");
strcpy(Room[7].Description2, "\n");
Room[7].Exit[North]=11;  
Room[7].Exit[East]=9;  
Room[7].Exit[West]=8;  
Room[7].Exit[South]=2;
//ROOM 8
strcpy(Room[8].RoomName, "Living Room");
strcpy(Room[8].Description, "\nBLAH\n\n");
Room[8].Exit[North]=0;  
Room[8].Exit[East]=7;  
Room[8].Exit[West]=0;  
Room[8].Exit[South]=0; 
//ROOM 9
strcpy(Room[9].RoomName, "Kitchen");
strcpy(Room[9].Description, "\nBLAH\n\n");
Room[9].Exit[North]=0;  
Room[9].Exit[East]=10;  
Room[9].Exit[West]=7;  
Room[9].Exit[South]=0;
//ROOM 10
strcpy(Room[10].RoomName, "Utility Room");
strcpy(Room[10].Description, "\nBLAH\n\n");
Room[10].Exit[North]=0;  
Room[10].Exit[East]=0;  
Room[10].Exit[West]=9;  
Room[10].Exit[South]=0;  
//ROOM 11
strcpy(Room[11].RoomName, "Upstairs Hallway");
strcpy(Room[11].Description, "\nBLAH\n\n");
Room[11].Exit[North]=13;  
Room[11].Exit[East]=14;  
Room[11].Exit[West]=12;  
Room[11].Exit[South]=7;  
//ROOM 12 
strcpy(Room[12].RoomName, "Bedroom 1");
strcpy(Room[12].Description, "\nBLAH\n\n");
Room[12].Exit[North]=0;  
Room[12].Exit[East]=11;  
Room[12].Exit[West]=0;  
Room[12].Exit[South]=0;  
//ROOM 13 
strcpy(Room[13].RoomName, "Bedroom 2");
strcpy(Room[13].Description, "\nBLAH\n\n");
Room[13].Exit[North]=0;  
Room[13].Exit[East]=0;  
Room[13].Exit[West]=0;  
Room[13].Exit[South]=11; 
//ROOM 14
strcpy(Room[14].RoomName, "Upstairs Bathroom");
strcpy(Room[14].Description, "\nBLAH\n\n");
Room[14].Exit[North]=0;  
Room[14].Exit[East]=0;  
Room[14].Exit[West]=11;  
Room[14].Exit[South]=0;   
//ROOM 15
strcpy(Room[15].RoomName, "Introduction");
strcpy(Room[15].Description, "\n\n%s stood in the centre of the road, fully aware of this shadowed eyes and \nslumped shoulders.");
strcpy(Room[15].Description2,"\nThe chill of night pinched his skin and woke him from his thoughts.\n\n");
Room[15].Exit[North]=1;  
Room[15].Exit[East]=0;  
Room[15].Exit[West]=0;  
Room[15].Exit[South]=0;   

}
I have writen the following to get a username:

Code:
{
char user[20];
 printf("What is your name?");
gets(user);
 printf("Your username is %s",user);
}
I do not understand how I can use this outside of the Main function. Do I need to assign it to a global variable?? If so I cannot work out how?! Any help would be appreciated.

Thanks.