Hi, first of all I would like to thank you for taking the time to look at my problem.
I'm trying to input to a multidimensional character array. The error occurs on the second array. I tried to understand the problem by varying my input, but it always occurs on the second array. It prompts for a second entry though. If you set the size as one and enter an applicable character array it returns to main and outputs that array.
I've tried to Google an answer but I couldn't identify my error. They always showed integer arrays. I think I could probably add the string library and make this all simple, but I'm a bit curious of how to do this with an actual character array and I have never used the string functions before.
Thank You for your time.
#include<iostream>
using namespace std;
int getsize();
void subdir(char **sub, int size);
int main()
{
int size,x; char *sub[10];
size = getsize();
*sub = new char[size];
subdir(sub,size);
for(x=0;x<size;x++)
cout << endl << sub[x] << endl;
}
int getsize()
{
int size;
cout << "Enter the size of array ";
cin >> size;
return size;
}
void subdir(char **sub,int size)
{
int x,y; char temp[12];
cout << "Enter Names in order\n";
for(x=0;x<size;x++)
{
cin >> temp;
for(y=0;temp[y]!=0;y++)
sub[x][y] = temp[y];
sub[x][y] = 0;
}
}