I'm having a bit of a problem with a two dimensional array of characters. The idea is that the program copies a bit of text using strcpy, and it's supposed to place it in the first line of that array. Where abouts in that line is determined by the length of the strings being copied and a for loop. That particular bit of code is here:
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<stdlib.h>
using namespace std;
#define NLOCATIONS 5
#define HTSIZE 80
#define VTSIZE 25
void main()
{
int i = 10;
char Table[VTSIZE][HTSIZE] = {0};
char szLocations[NLOCATIONS][20] = {"Terminal", "Passenger lounge", "Crew lounge", "Service area", "Private lounge"};
switch(cMenuOption)
{
case '4':
for(y=0; y<NLOCATIONS; y++)
{
strcpy(Table[0][i],szLocations[y]);
i = i + strlen(szLocations[y]);
}
cout << Table << endl;
break;
}
}
I believe that the problem is due to the fact that I'm trying to copy several strings to one line of the array, and I can only set the start coordinate for that string to be copied to, but the program only wants to set the string in position i, which obviously only allowes one character. Is there any way I can change this to do what I want it to do?
Thanks