Question about dynamic strings
When i compile my code I get an error for this piece of code
1 2
|
char *st[81];
st=new char [n][81];
|
The error is
error C2440: '=' : cannot convert from 'char (*)[81]' to 'char *[81]'
Somewhere I read that I should instead use this
1 2
|
char (*st) [81];
st=new char [n][81];
|
Can somebody explain to me why are the brackets needed. I have only worked with dynamic arrays before and there the brackets were not needed.
char *st[81]
Is a an 81-element array of char*, whereas char (*st)[81]
is a dynamic array of length 81 char arrays.
Topic archived. No new replies allowed.