Here is what I am doing. I am writing my own ini file reader.
Pretend this is the file:
Code:
#Comment 1
[Main]
string=none
numeric=6
#Comment 2
[Other]
string=hello
numeric=19
Here is how I want it to be layed out in a variable;
Code:
data[0] = "[Main]"
data[0][0] = "string=none"
data[0][1] = "numeric=6"
data[1] = "[Other]"
data[1][0] = "string=hello"
data[1][1] = "numeric=19"
Hopefully you can see my pattern. I am declaring my variable to be used like this:
Code:
char **data = NULL;
I already have my functions to hand me my data, all I need to do now is to allocate the correct space and assign the data to it.
I am having a lot of trouble here. Right now I just want to at least get the "sections" of the ini written (they go into the 1d part of the array). Here is what I have been currently trying to work with:
Code:
data[l] = (char *)realloc(data[l], (sizeof(char) * ((j - i) + 1)));
l++;
strncpy(data[l-1], &buffer[i], j - i);
j - i return the length of the "section". I also am not getting very good error details, just a "yourprog has stopped working..."
By the way, this is on windows.