Hi! I was looking for some help on this matter and found this: http://bytes.com/forum/thread643133.ht ml which... I didn't 100% got.
So... I'll try to explain what I need:
array[0] = "First string"
array[1] = "Second string"
array[2] = "This is the third one"
.
.
.
array[n] = "Hola"
I have a dynamic array of fixed-length strings. At the very beginning I create it on a struct, like this:
Where CHARMAX is, let's say, 30. So it's an array of strings of 29 characters + \0.
Then, I discover the size of datoString (given by user) and I try to to this:
I know I'm mixing nombre and datoString, but I dind't know how to get "sizeof(arr ay datoString[CHARMAX]".
I don't know if I'm being clear...
If the user says "12", then the array would be char[12][30], but... How do I do that dinamycally and how do I allocate memory?
Please heeeeeelp :'(
And thanks in advance ;)
So... I'll try to explain what I need:
array[0] = "First string"
array[1] = "Second string"
array[2] = "This is the third one"
.
.
.
array[n] = "Hola"
I have a dynamic array of fixed-length strings. At the very beginning I create it on a struct, like this:
Code:
char* datoString[CHARMAX]; char nombre[CHARMAX];
Then, I discover the size of datoString (given by user) and I try to to this:
Code:
datoString = calloc(sizeGivenByUser, sizeof(nombre));
I don't know if I'm being clear...
If the user says "12", then the array would be char[12][30], but... How do I do that dinamycally and how do I allocate memory?
Please heeeeeelp :'(
And thanks in advance ;)
Comment